{"trustable":false,"prependHtml":"\u003cstyle type\u003d\u0027text/css\u0027\u003e\n .input, .output {\n border: 1px solid #888888;\n }\n .output {\n margin-bottom: 1em;\n position: relative;\n top: -1px;\n }\n .output pre, .input pre {\n background-color: #EFEFEF;\n line-height: 1.25em;\n margin: 0;\n padding: 0.25em;\n }\n \u003c/style\u003e\n \u003clink rel\u003d\"stylesheet\" href\u003d\"//codeforces.org/s/96598/css/problem-statement.css\" type\u003d\"text/css\" /\u003e\n\u003cscript\u003e\n window.katexOptions \u003d {\n delimiters: [\n {left: \u0027$$$$$$\u0027, right: \u0027$$$$$$\u0027, display: true},\n {left: \u0027$$$\u0027, right: \u0027$$$\u0027, display: false},\n {left: \u0027$$\u0027, right: \u0027$$\u0027, display: true},\n {left: \u0027$\u0027, right: \u0027$\u0027, display: false}\n ]\n };\n\u003c/script\u003e\n","sections":[{"title":"","value":{"format":"MD","content":"给定两个排列 $a$ 和 $b$,要求支持两种操作:\n* ``1 l1 r1 l2 r2`` 表示询问问有多少个元素同时出现在 $a$ 的子区间 [l1, r1] 和 $b$ 的子区间 [l2, r2] 中;\n* ``2 x y`` 表示交换排列中的第 x 个和第 y 个元素。\n\n---\n\n\u003cp\u003eYou are given two permutations $$$a$$$ and $$$b$$$, both consisting of $$$n$$$ elements. Permutation of $$$n$$$ elements is such a integer sequence that each value from $$$1$$$ to $$$n$$$ appears exactly once in it.\u003c/p\u003e\n\u003cp\u003eYou are asked to perform two types of queries with them:\u003c/p\u003e\n\u003cul\u003e\n \u003cli\u003e$$$1~l_a~r_a~l_b~r_b$$$ — calculate the number of values which appear in both segment $$$[l_a; r_a]$$$ of positions in permutation $$$a$$$ and segment $$$[l_b; r_b]$$$ of positions in permutation $$$b$$$;\u003c/li\u003e\n \u003cli\u003e$$$2~x~y$$$ — swap values on positions $$$x$$$ and $$$y$$$ in permutation $$$b$$$.\u003c/li\u003e\n\u003c/ul\u003e\n\u003cp\u003ePrint the answer for each query of the first type.\u003c/p\u003e\n\u003cp\u003eIt is guaranteed that there will be at least one query of the first type in the input.\u003c/p\u003e"}},{"title":"Input","value":{"format":"MD","content":"\u003cp\u003eThe first line contains two integers $$$n$$$ and $$$m$$$ ($$$2 \\le n \\le 2 \\cdot 10^5$$$, $$$1 \\le m \\le 2 \\cdot 10^5$$$) — the number of elements in both permutations and the number of queries.\u003c/p\u003e\n\u003cp\u003eThe second line contains $$$n$$$ integers $$$a_1, a_2, \\dots, a_n$$$ ($$$1 \\le a_i \\le n$$$) — permutation $$$a$$$. It is guaranteed that each value from $$$1$$$ to $$$n$$$ appears in $$$a$$$ exactly once.\u003c/p\u003e\n\u003cp\u003eThe third line contains $$$n$$$ integers $$$b_1, b_2, \\dots, b_n$$$ ($$$1 \\le b_i \\le n$$$) — permutation $$$b$$$. It is guaranteed that each value from $$$1$$$ to $$$n$$$ appears in $$$b$$$ exactly once.\u003c/p\u003e\n\u003cp\u003eEach of the next $$$m$$$ lines contains the description of a certain query. These are either:\u003c/p\u003e\n\u003cul\u003e\n \u003cli\u003e$$$1~l_a~r_a~l_b~r_b$$$ ($$$1 \\le l_a \\le r_a \\le n$$$, $$$1 \\le l_b \\le r_b \\le n$$$);\u003c/li\u003e\n \u003cli\u003e$$$2~x~y$$$ ($$$1 \\le x, y \\le n$$$, $$$x \\ne y$$$).\u003c/li\u003e\n\u003c/ul\u003e"}},{"title":"Output","value":{"format":"MD","content":"\u003cp\u003ePrint the answers for the queries of the first type, each answer in the new line — the number of values which appear in both segment $$$[l_a; r_a]$$$ of positions in permutation $$$a$$$ and segment $$$[l_b; r_b]$$$ of positions in permutation $$$b$$$.\u003c/p\u003e"}},{"title":"Sample 1","value":{"format":"MD","content":"\u003ctable class\u003d\u0027vjudge_sample\u0027\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003eInput\u003c/th\u003e\n \u003cth\u003eOutput\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003e6 7\n5 1 4 2 3 6\n2 5 3 1 4 6\n1 1 2 4 5\n2 2 4\n1 1 2 4 5\n1 2 3 3 5\n1 1 6 1 2\n2 4 1\n1 4 4 1 3\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e1\n1\n1\n2\n0\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}},{"title":"Note","value":{"format":"MD","content":"\u003cp\u003eConsider the first query of the first example. Values on positions $$$[1; 2]$$$ of $$$a$$$ are $$$[5, 1]$$$ and values on positions $$$[4; 5]$$$ of $$$b$$$ are $$$[1, 4]$$$. Only value $$$1$$$ appears in both segments.\u003c/p\u003e\n\u003cp\u003eAfter the first swap (the second query) permutation $$$b$$$ becomes $$$[2, 1, 3, 5, 4, 6]$$$.\u003c/p\u003e\n\u003cp\u003eAfter the second swap (the sixth query) permutation $$$b$$$ becomes $$$[5, 1, 3, 2, 4, 6]$$$.\u003c/p\u003e"}}]}