#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 NN seaside villages on X island, numbered from 11 to NN. NN roads are built to connect all of them, which are also numbered from 11 to NN, and the road with number ii connects the village ii and ii % N+1N + 1. 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 ii are blocked or unblocked, or ask you if village ii and jj 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 TT, which indicate the number of test cases. The very first line of each case contains two integers, NN and MM. NN (where 2N1000002\leq N\leq 100000) is the total number of the villages, MM (where 1M1000001\leq M\leq 100000) is the number of queries. The next MM lines each describe one query. For each line, the first integer (00 or 11) indicates the type of the query. If the first integer is 00, there will be another integer ii followed, if the road ii is blocked at present, it will be unblocked, and vice versa. If the query type is 11, there will be two more integers ii and jj followed, if the village ii and jj are connected at present, the answer is 11, otherwise it shall be 00.

Output

For each query of type 11, 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