Given a rooted tree with $$$n$$$ nodes, rooted at $$$1$$$, which satisfies the property $$$p_i \lt i$$$, where $$$p_i$$$ is the parent node of $$$i$$$.
For each node $$$u$$$, for all its children $$$v$$$, we will provide the index of the centroid of the new tree formed by only considering $$$v$$$ and the nodes in the subtree of $$$v$$$, noting that we will not give you the index of $$$v$$$. If a tree has two centroids, we will tell you the one that is deeper in the original tree. Your task is to construct a tree that satisfies the above conditions.
The centroid of a tree: If a certain node is chosen and removed from the tree, the tree will be divided into several subtrees. The number of nodes in each subtree is counted, and the maximum value is recorded. The node for which this maximum value is minimized when considering all nodes in the tree is called the centroid of the entire tree.
The first line contains an integer $$$T$$$ $$$(1 \leq T \leq 10^5)$$$, representing the number of test cases.
For each test case, the first line contains an integer $$$n$$$ $$$(2\leq n \leq 2\cdot 10^5)$$$, representing the number of nodes in the tree.
The next $$$n$$$ lines provide first an integer $$$c_i$$$ $$$(1\leq c_i\leq n)$$$, representing the number of children of node $$$i$$$, followed by $$$c_i$$$ integers $$$p_{i,j}$$$ $$$(1\leq p_{i,j}\leq n)$$$, representing the index of the centroid of the tree formed by the $$$j$$$-th child of $$$i$$$ and the nodes in its subtree.
The sum of $$$n$$$ across all test cases does not exceed $$$2\cdot 10^5$$$.
For each test case, output $$$n-1$$$ lines. The $$$i$$$-th line should output two integers $$$u,v$$$ $$$(1\leq u,v \leq n, u\neq v)$$$, representing an edge $$$(u,v)$$$ in the tree.
The test data guarantees a solution. If there are multiple valid solutions, any one of them is acceptable.
242 3 41 30031 31 30
2 3 1 2 1 4 2 3 1 2