{"trustable":true,"sections":[{"title":"","value":{"format":"HTML","content":"\u003cp\u003eAs everyone knows, there are innumerable \"world lines\" representing different worlds. Every tiny change maybe creates a new world line.\u003c/p\u003e\n\u003cp\u003eIt is 9102 A.D. now and human beings have lived on Mars for thousands of years, forming a lot of tribes. Every tribe contains one or more families. Two tribes can go to integration, which all families in one tribe move to the other; One family may become extinct or migrate from their original tribe to another family\u0027s tribe.\u003c/p\u003e\n\u003cp\u003eYou are ruling the universe as Creator so that you know everything on Mars. Because of the reason that you usually forget things, you decide to write a program to manage these happening things.\u003c/p\u003e\n\u003cp\u003eSuppose that there are $n$ tribes on Mars and at the beginning, each tribe consists of the unique family. We number these tribes as well as these families from $1$ to $n$. Your program needs to support the following five types of operations:\u003c/p\u003e\n\u003cul\u003e\n \u003cli\u003e\u003ccode\u003e1 k a b\u003c/code\u003e: merge the tribe containing the $a$-th family and the tribe containing the $b$-th family;\u003c/li\u003e\n \u003cli\u003e\u003ccode\u003e2 k a\u003c/code\u003e: make the $a$-th family into extermination;\u003c/li\u003e\n \u003cli\u003e\u003ccode\u003e3 k a b\u003c/code\u003e: the $a$-th family moves away from their tribe and join in the tribe containing the $b$-th family;\u003c/li\u003e\n \u003cli\u003e\u003ccode\u003e4 k a b\u003c/code\u003e: report that if the $a$-th family and the $b$-th one belong to the same tribe;\u003c/li\u003e\n \u003cli\u003e\u003ccode\u003e5 k a\u003c/code\u003e: report the total number of families in the tribe which contains the $a$-th family.\u003c/li\u003e\n\u003c/ul\u003e\n\u003cp\u003eNote that for each given operation with a parameter $k$, you will place yourself in the world line at the time after the $k$-th operation.\u003c/p\u003e\n\u003cp\u003eIt is possible that the $a$-th family and the $b$-th one are in the same tribe when you deal with an operation of type $1$ or $3$, then nothing will happen. It is also possible that given numbers $a$ or $b$ indicates to an exterminated family, then nothing will happen for the first three types of operations, and the report should be \u003ccode\u003eNo\u003c/code\u003e for the fourth type of operation, and \u003ccode\u003e0\u003c/code\u003e for the fifth one.\u003c/p\u003e\n\u003ch3\u003eInput\u003c/h3\u003e\n\u003cp\u003eThe first line contains two numbers $n$ and $m$ ($1 \\leq n, m \\leq 1000000$), representing the initial number of families and operations.\u003c/p\u003e\n\u003cp\u003eThe next $m$ lines contain five kinds of operations. The $i$-th line contains three or four numbers $op_i$, $k_i$, $a_i$ and $b_i$ ($1 \\leq op_i \\leq 5, 0 \\leq k_i \\leq i-1, 1 \\leq a_i, b_i \\leq n$).\u003c/p\u003e\n\u003ch3\u003eOutput\u003c/h3\u003e\n\u003cp\u003eFor operation $4$, you need to output one line \u003ccode\u003eYes\u003c/code\u003e or \u003ccode\u003eNo\u003c/code\u003e (without quotes); for operation $5$, you need to output one line contains a number.\u003c/p\u003e"}},{"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\u003e4 6 \n1 0 1 2 \n1 0 4 2 \n3 2 4 3 \n5 3 3 \n2 1 1 \n4 5 3 4\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e2\nNo\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n\u003cbr /\u003e\u003cp\u003e\u003cimg src\u003d\"https://res.jisuanke.com/img/upload/20191114/741d7f1675ea1d69c6d1a660b2f33e1e441cedb8.png\" alt\u003d\"\"\u003e\u003c/p\u003e"}}]}