Graph Games
时间限制:C/C++/Rust/Pascal 2秒,其他语言4秒
空间限制:C/C++/Rust/Pascal 512 M,其他语言1024 M
64bit IO Format: %lld

题目描述

You are given an undirected graph with  vertices and   edges. The edges are numbered from  to   . Denote the set   as: All the vertices we can reach from vertex    by exactly one edge.

You are supposed to deal with  operations of the following two types:
  1. -- reverse the status of edges numbered between   to    . i.e. Delete the edge if it is in the graph, otherwise add it to the graph. 
  2. -- ask whether    and    are exactly the same .

Note that all the   edges are in the graph at the beginning.

输入描述:

The input contains multiple cases. The first line of the input contains a single positive integer  , the number of cases.

For each case, the first line contains two integers   and , the number of vertices and edges in the graph. In the following   lines, the -th line contains two integers  , describing the the -th edge (u_i,v_i) . Each edge appears in the input at most once. The -th line contains a integer  , the number of operations. In the following   lines, each line contains three integers, describing an operation.

The total sum of  over all cases does not exceed . The total sum of over all cases does not exceed . The total sum of   over all cases does not exceed .

输出描述:

For each case, print a string in a line. The length of the string should equal the number of operations of type . If the answer is yes, the -th character of the string should be `1', otherwise it should be `0'. Check the samples for more details.

示例1

输入

复制
1
5 4
1 2
1 3
4 2
4 3
3
2 1 4
1 1 1
2 1 2

输出

复制
10