#Lutece0106. Blocked Road
Blocked Road
Migrated from Lutece 106 Blocked Road
All parts of this problem, including description, images, samples, data and checker, might be broken. If you find bugs in this problem, please contact the admins.
Description
There are seaside villages on X island, numbered from to . roads are built to connect all of them, which are also numbered from to , and the road with number connects the village and % . Sometimes, for some reasons, some roads are blocked, so some villages are not connected anymore. Now, you are assigned to write a program to offer dynamic information about the connectivity.
At first, all roads are not blocked. The input will tell you the road with number are blocked or unblocked, or ask you if village and are connected. Here two villages are connected means we can reach another village from one via some unblocked road. BTW, all the roads are bidirectional.
Input
The first line of the input contains one integer , which indicate the number of test cases. The very first line of each case contains two integers, and . (where ) is the total number of the villages, (where ) is the number of queries. The next lines each describe one query. For each line, the first integer ( or ) indicates the type of the query. If the first integer is , there will be another integer followed, if the road is blocked at present, it will be unblocked, and vice versa. If the query type is , there will be two more integers and followed, if the village and are connected at present, the answer is , otherwise it shall be .
Output
For each query of type , output its answer in a single line
Samples
1
5 10
1 2 5
0 4
1 4 5
0 2
1 3 4
1 1 3
0 1
0 2
1 2 4
1 2 5
1
1
1
0
1
0
Resources
The 7th UESTC Programming Contest Final