Gotham’s Rail Track

Gothams railway track is made using rail blocks connected using joint bars. A rail block is made using two parallel rail and perpendicularly laid sleepers. In rail tracks a rail block can be connected to at most two other rail blocks. Several rail blocks are connected using joint bars to create a rail track. In this problem you are going to work with N rail blocks numbered from 1 to N and will be given following three types of queries: 1 u v—connectblockuandv(1≤u,v≤N andu̸=v)(anymomentablockwillbeconnected to at most two blocks). 2 u v — disconnect block u and v (it is ensured that this query will only disconnect existing connections). Two blocks u and v is considered connected if and only if there was a 1 u v or 1 v u query performed and no 2 u v or 2 v u query is performed after that. 3 u v — output the longest distance between u and v, distance between two blocks is equal to number of rail blocks in a path from u to v (including u, v). If there is no path then output ‘-1’. Input Input starts with an integer T (T ≤ 5) denoting the number of test cases. First line of each test case contains two integers N (2 ≤ N ≤ 105) and Q (1 ≤ Q ≤ 105). The next Q lines contain queries as described above. Output For each case print the case number in the first line. Then for each query ‘3 u v’ print the answer in separate line. See sample input output for more details. Sample Input 1 56 112 134 113 314 234 314 Sample Output Case 1: 3 -1