Given n rooted trees T_1,T_2,…,T_n, find two permutations p_1,p_2,…,p_n and q_1,q_2,…,q_n such that the diameter of T_p_1×T_p_2×…×T_p_n is maximum and the diameter of T_q_1×T_q_2×…×T_q_n is minimum.
For two rooted trees A and B, their tree product T=A×B is defined as follows: copy tree A, and then for each vertex x in it, make a copy of B and merge its root with vertex x. See the table below for an example:

It can be shown that tree product is associative: (A×B)×C=A×(B×C). So the parentheses in a product of three or more trees can be omitted.
Recall that:
There are multiple test cases. The first line of input contains an integer T, indicating the number of test cases. For each test case:
The first line contains an integer n (1≤n≤106), indicating the number of rooted trees.
Each of the next n lines starts from an integer m_i (1≤m_i≤105), indicating the number of vertices in the i-th rooted tree. It is followed by m_i integers p_i,1,p_i,2,…,p_i,m_i (0≤p_i,j≤m_i) on the same line, where the j-th of them denotes the parent of the j-th vertex. The root of the tree has 0 as parent.
It is guaranteed that the sum of m_i over all test cases does not exceed 106.
For each test case, output two integers: the maximum and the minimum diameter, in that order.
For the first sample test case, T_1×T_2×T_3 will provide the maximum diameter, while T_3×T_2×T_1 will provide the minimum diameter.