{"trustable":true,"prependHtml":"\u003cstyle type\u003d\"text/css\"\u003e\n section pre {\n display: block;\n padding: 9.5px;\n margin: 0 0 10px;\n font-size: 13px;\n line-height: 1.42857143;\n word-break: break-all;\n word-wrap: break-word;\n color: #333;\n background: rgba(255, 255, 255, 0.5);\n border: 1px solid #ccc;\n border-radius: 6px;\n }\n\u003c/style\u003e\n\u003cscript\u003e\n window.katexOptions \u003d {\n delimiters: [\n {left: \u0027\\\\(\u0027, right: \u0027\\\\)\u0027, display: false},\n {left: \u0027\\\\[\u0027, right: \u0027\\\\]\u0027, display: true}\n ]\n };\n\u003c/script\u003e\n","sections":[{"title":"Problem Statement","value":{"format":"HTML","content":"\r\n\u003csection\u003e\r\n\u003cp\u003e\u003cvar\u003e\\(N\\)\u003c/var\u003e students are about to go to school. Student \u003cvar\u003e\\(i\\)\u003c/var\u003e belongs to Class \u003cvar\u003e\\(C_i\\)\u003c/var\u003e.\u003c/p\u003e\r\n\u003cp\u003eAfter 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.\u003c/p\u003e\r\n\u003cp\u003eYou will be given \u003cvar\u003e\\(Q\\)\u003c/var\u003e queries that should be processed in order. There are two kinds of queries, in the following formats, that mean the following:\u003c/p\u003e\r\n\u003cul\u003e\r\n\u003cli\u003e\u003ccode\u003e1 a b\u003c/code\u003e: The group containing Student \u003cvar\u003e\\(a\\)\u003c/var\u003e and the group containing Student \u003cvar\u003e\\(b\\)\u003c/var\u003e merges. (If they are already in the same group, nothing happens.)\u003c/li\u003e\r\n\u003cli\u003e\u003ccode\u003e2 x y\u003c/code\u003e: You are asked to find the number of students belonging to Class \u003cvar\u003e\\(y\\)\u003c/var\u003e who are already in the same group as Student \u003cvar\u003e\\(x\\)\u003c/var\u003e (including Student \u003cvar\u003e\\(x\\)\u003c/var\u003e) at the time of this query.\u003c/li\u003e\r\n\u003c/ul\u003e\r\n\u003c/section\u003e\r\n"}},{"title":"Constraints","value":{"format":"HTML","content":"\r\n\u003csection\u003e\r\n\u003cul\u003e\r\n\u003cli\u003e\u003cvar\u003e\\(1 \\leq N \\leq 2 \\times 10^5\\)\u003c/var\u003e\u003c/li\u003e\r\n\u003cli\u003e\u003cvar\u003e\\(1 \\leq Q \\leq 2 \\times 10^5\\)\u003c/var\u003e\u003c/li\u003e\r\n\u003cli\u003e\u003cvar\u003e\\(1 \\leq C_i,a,b,x,y \\leq N\\)\u003c/var\u003e\u003c/li\u003e\r\n\u003cli\u003eIn a query in the format \u003ccode\u003e1 a b\u003c/code\u003e, \u003cvar\u003e\\(a \\neq b\\)\u003c/var\u003e.\u003c/li\u003e\r\n\u003cli\u003eAll values in input are integers.\u003c/li\u003e\r\n\u003c/ul\u003e\r\n\u003c/section\u003e\r\n"}},{"title":"Input","value":{"format":"HTML","content":"\r\n\u003csection\u003e\r\n\u003cp\u003eInput is given from Standard Input in the following format:\u003c/p\u003e\r\n\u003cpre\u003e\u003cvar\u003e\\(N\\)\u003c/var\u003e \u003cvar\u003e\\(Q\\)\u003c/var\u003e\r\n\u003cvar\u003e\\(C_1\\)\u003c/var\u003e \u003cvar\u003e\\(\\ldots\\)\u003c/var\u003e \u003cvar\u003e\\(C_N\\)\u003c/var\u003e\r\n\u003cvar\u003e\\(Query_1\\)\u003c/var\u003e\r\n\u003cvar\u003e\\(\\vdots\\)\u003c/var\u003e\r\n\u003cvar\u003e\\(Query_Q\\)\u003c/var\u003e\r\n\u003c/pre\u003e\r\n\r\n\u003c/section\u003e\r\n"}},{"title":"Output","value":{"format":"HTML","content":"\r\n\u003csection\u003e\r\n\u003cp\u003ePrint the answers to the queries in the format \u003ccode\u003e2 x y\u003c/code\u003e, each in its own line, in order.\u003c/p\u003e\r\n\u003c/section\u003e\r\n"}},{"title":"Sample 1","value":{"format":"HTML","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\u003e5 5\r\n1 2 3 2 1\r\n1 1 2\r\n1 2 5\r\n2 1 1\r\n1 3 4\r\n2 3 4\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e2\r\n0\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n\r\n\u003csection\u003e\r\n\r\n\r\n\u003c/section\u003e\r\n\r\n\u003csection\u003e\r\n\r\n\r\n\u003cp\u003eAt the time of the \u003cvar\u003e\\(3\\)\u003c/var\u003e-rd query, Student \u003cvar\u003e\\(1\\)\u003c/var\u003e has joined up with Student \u003cvar\u003e\\(2\\)\u003c/var\u003e and \u003cvar\u003e\\(5\\)\u003c/var\u003e. Among these three students, two belong to Class \u003cvar\u003e\\(1\\)\u003c/var\u003e.\u003c/p\u003e\r\n\u003cp\u003eAt the time of the \u003cvar\u003e\\(5\\)\u003c/var\u003e-th query, Student \u003cvar\u003e\\(3\\)\u003c/var\u003e has joined up with Student \u003cvar\u003e\\(4\\)\u003c/var\u003e. Among these two students, none belongs to Class \u003cvar\u003e\\(4\\)\u003c/var\u003e.\u003c/p\u003e\r\n\u003c/section\u003e\r\n"}},{"title":"Sample 2","value":{"format":"HTML","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\u003e5 4\r\n2 2 2 2 2\r\n1 1 2\r\n1 1 3\r\n1 2 3\r\n2 2 2\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e3\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n\r\n\u003csection\u003e\r\n\r\n\r\n\u003c/section\u003e\r\n\r\n\u003csection\u003e\r\n\r\n\r\n\u003cp\u003eThere may be queries in the format \u003ccode\u003e1 a b\u003c/code\u003e for students who already belong to the same group.\u003c/p\u003e\r\n\u003c/section\u003e\r\n"}},{"title":"Sample 3","value":{"format":"HTML","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\u003e12 9\r\n1 2 3 1 2 3 1 2 3 1 2 3\r\n1 1 2\r\n1 3 4\r\n1 5 6\r\n1 7 8\r\n2 2 1\r\n1 9 10\r\n2 5 6\r\n1 4 8\r\n2 6 1\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e1\r\n0\r\n0\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n\r\n\u003csection\u003e\r\n\r\n\r\n\u003c/section\u003e\r\n\r\n\u003csection\u003e\r\n\u003c/section\u003e\r\n"}}]}