Each test contains multiple test cases.
The first line contains an integer TTT (1≤T≤1051\leq T\leq 10^51≤T≤105) — the number of test cases.
For each test case:
The first line contains a single integer nnn (1≤n≤2×1051\leq n\leq 2\times 10^51≤n≤2×105) — the number of the available arguments.
For the iii-th line in the following nnn lines, there is an integer kik_iki (0≤ki<n0\le k_{i} < n0≤ki<n) followed by kik_iki integers ai,1,ai,2,…,ai,kia_{i,1},a_{i,2},\dots,a_{i,k_i}ai,1,ai,2,…,ai,ki (1≤ai,j≤n,ai,j≠i1\le a_{i,j}\le n,a_{i,j}\neq i1≤ai,j≤n,ai,j=i) — the arguments required to make the conclusion for the iii-th argument. It is guaranteed that ai,j≠ia_{i,j}\neq iai,j=i for all iii (1≤i≤n1\leq i\leq n1≤i≤n), and ai,j≠ai,ka_{i,j}\neq a_{i,k}ai,j=ai,k when j≠kj\neq kj=k.
It is guaranteed that the sum of nnn in all the test cases does not exceed 2×1052\times 10^52×105 and the sum of kik_iki in all the test cases does not exceed 5×1055\times 10^55×105.