{"raw_statement":[{"iden":"problem statement","content":"$N$ students are about to go to school. Student $i$ belongs to Class $C_i$.\nAfter leaving home, each student will head to school while repeatedly joining up with a group of other students. Once students join up with each other, they will not separate.\nYou will be given $Q$ queries that should be processed in order. There are two kinds of queries, in the following formats, that mean the following:\n\n*   `1 a b`: The group containing Student $a$ and the group containing Student $b$ merges. (If they are already in the same group, nothing happens.)\n*   `2 x y`: You are asked to find the number of students belonging to Class $y$ who are already in the same group as Student $x$ (including Student $x$) at the time of this query."},{"iden":"constraints","content":"*   $1 \\leq N \\leq 2 \\times 10^5$\n*   $1 \\leq Q \\leq 2 \\times 10^5$\n*   $1 \\leq C_i,a,b,x,y \\leq N$\n*   In a query in the format `1 a b`, $a \\neq b$.\n*   All values in input are integers."},{"iden":"input","content":"Input is given from Standard Input in the following format:\n\n$N$ $Q$\n$C_1$ $\\ldots$ $C_N$\n$Query_1$\n$\\vdots$\n$Query_Q$"},{"iden":"sample input 1","content":"5 5\n1 2 3 2 1\n1 1 2\n1 2 5\n2 1 1\n1 3 4\n2 3 4"},{"iden":"sample output 1","content":"2\n0\n\nAt the time of the $3$\\-rd query, Student $1$ has joined up with Student $2$ and $5$. Among these three students, two belong to Class $1$.\nAt the time of the $5$\\-th query, Student $3$ has joined up with Student $4$. Among these two students, none belongs to Class $4$."},{"iden":"sample input 2","content":"5 4\n2 2 2 2 2\n1 1 2\n1 1 3\n1 2 3\n2 2 2"},{"iden":"sample output 2","content":"3\n\nThere may be queries in the format `1 a b` for students who already belong to the same group."},{"iden":"sample input 3","content":"12 9\n1 2 3 1 2 3 1 2 3 1 2 3\n1 1 2\n1 3 4\n1 5 6\n1 7 8\n2 2 1\n1 9 10\n2 5 6\n1 4 8\n2 6 1"},{"iden":"sample output 3","content":"1\n0\n0"}],"translated_statement":null,"sample_group":[],"show_order":["default"],"formal_statement":null,"simple_statement":null,"has_page_source":true}