 Final
 Elimination
 Third qual
 Second qual
 First qual
 Warmup
Elimination round completed
Tasks
Show one task per page / all tasks on one page
Time limit  4 seconds 

Memory limit  256 megabytes 
Consider a rooted tree. Let us consider a vertex v that has at least one vertex in its subtree that has distance k from v. Let us call a tree that we get from a subtree rooted at v by removing all vertices that are at distance greater than k from v its ksubtree rooted at v. For example, the picture below shows 2subtree of the vertex 3 in red.
Let us call two subtrees equal, if it is possible to renumber vertices of one of them to get the other one. You are not allowed to change the order of children of a vertex. For example, the following two trees are not equal:
You are given a rooted tree. Find the greatest k such that the given tree has two equal ksubtrees with different roots. These trees are allowed to have vertices in common.
The picture shows trees from sample test.
The first example has equal 1subtrees rooted at 2 and 3.
The second example has equal 3subtrees rooted at 1 and 4.
The third example has equal 0subtrees rooted at 1 and 2.
Input format 
Input data contains multiple test cases. The first line contains t — the number of tests (1 ≤ t ≤ 10^{4}). Each of the following t test is described in the following way: the first line contains one integer n — the number of vertices (2 ≤ n ≤ 10^{5}). The following n lines describe vertices, the ith of them first contains an integer cnt_{i} — the number of vertices of the vertex i, followed by cnt_{i} integers — numbers of the children of the ith vertex, in order. Vertices are numbered starting from 1. The root of the tree is the vertex number 1. It is guaranteed that the graph is the correct tree rooted at 1. The sum of values of n for all tests in one input data doesn't exceed 2·10^{5}. 

Output format 
For each test case output maximal k such that there are two equal ksubtrees with different roots. 
Examples 
Input data
3 5 2 2 3 1 4 1 5 0 0 8 1 2 2 3 4 0 1 5 2 6 7 0 1 8 0 2 1 2 0
Output data
1 3 0 
