Two undirected graphs of size

are equivalent in connectivity when there is a path from

to

in one graph if and only if there is a path from

to

in the other graph for all

.
Given

graphs

,

,

,

of size

, for each

,

,

,

, there exists

such that

can be derived from

by adding or removing an edge. Divide them into groups, such that two graphs are in the same groups if and only if they are equivalent in connectivity.
输入描述:
There are multiple test cases. The first line of input contains an integer
(
), the number of test cases. For each test case:
The first line contains three integers
,
and
(
,
,
) - the number of graphs, the number of vertices of each graph, and the number of edges of
.
Each of the following
lines contains two integers
and
(
), denoting an edge of
connecting
and
. It is guaranteed that there are no multiple edges in
.
The
-th of following
lines contains an integer
, a string
, and two integers
and
(
,
).
is one of "add" and "remove"
If
"add",
is derived from
by adding an edge connecting
and
. It is guaranteed that there does not exist the edge in
.
If
"remove",
is derived from
by removing an edge connecting
and
. It is guaranteed that there exists the edge in
.
It is guaranteed that the sum of
, the sum of
, and the sum of
in all test cases do not exceed
.
输出描述:
For each test case:
Output an integer
- the number of the groups in the first line.
For each group, output an integer
and
integers - the size of the group and the numbers of graphs in one line.
You can output the groups and the graphs in any order.
示例1
输入
复制
2
15 11 8
6 11
1 6
6 9
6 8
1 2
1 5
9 10
2 5
1 add 3 11
1 add 2 3
3 add 5 8
4 add 5 11
3 add 7 10
1 add 6 10
3 add 3 10
1 remove 6 8
5 add 4 9
1 add 2 9
8 add 7 8
3 add 2 4
1 remove 6 9
10 remove 6 9
14 5 2
1 5
1 4
1 add 2 4
1 add 3 4
1 add 2 4
4 add 3 4
4 add 1 3
5 add 1 3
2 add 2 3
1 add 1 2
4 add 3 4
3 add 4 5
9 add 2 3
3 remove 1 5
3 remove 3 4
输出
复制
7
2 10 13
5 2 3 4 5 8
3 1 7 11
1 14
2 6 12
1 9
1 15
5
3 2 4 9
6 5 6 7 8 10 12
2 1 14
2 3 11
1 13