Graph Cards
Time limit30sMemory limit1024 MB
Count how many of the given connected graphs are pairwise non-isomorphic, where each card gives its edge list and has as many edges as nodes.
Problem
A deck of graph cards is placed on the table. Each graph card is decorated with an undirected simple graph . Each is connected and has the same number of nodes and edges. Different graph cards may have different numbers of nodes.

Two graph cards are identical if and only if their graphs and are isomorphic. That is, there is a bijection from to such that for all , if and only if . The goal is to count the distinct graph cards in the deck.
Input
The first line contains an integer , the number of test cases. Each test case begins with a line containing the number of graph cards . Then lines follow, each describing one graph card in this format:
k u1 v1 u2 v2 ... uk vk
Here is the number of nodes, which is also the number of edges. For each , is an edge. Node identifiers are integers in .
Output
For each test case, print the number of distinct graph cards in the deck on its own line.
Constraints
- For each test case, the node counts of the graph cards sum to at most .