Who is the best teacher?

Time Limit: 3000MS

Memory Limit: 65535K

Description

There are N teachers in a school, each has Ti students. The teachers decide to hold a race among their students to see who teaches best students. The students will get constant points in a race.

Here is the rule:

In each race, each teacher send one student to compete, and his students take turns to compete with others. That is to say, if the jth student compete in race 1 and he will be sent to compete in race 1+Ti (if the teacher hasn't got the prize yet). In a race, we choose the student who gets the highest score, then the teacher of student wins the prize and he is not included in the remaining races among other teachers(Because he is excellent now). If there are more than one student with highest score, we will then not let any get the prize and head to the next.

We are interested in whether all teachers are excellent at teaching and how many races should the school hold when the last good teacher get the prize. You might write a program to help us.

Input

The first line of contains a single integer T, indicating the number of test cases. (1<=T<=15)

Each test case begins with an integer N(1<=N<=500), the number of teachers.

In the following N lines, each line contains an integer Ti(1<=Ti<=10), indicating the number of students of the i-th teacher, then Ti integers Mj(0<=Mj<=250) follow, indicating the constant points the j-th student get in each race.

Output

For each test case, print a single line containing two integers E, C, indicating the number of teachers that is not so excellent at teaching as others, and the number of races held when the last excellent teacher get the prize. If all teachers are with equal level in teaching, the second number should be 0.


Sample Input

1
4
3 2 9 4
1 3 
2 3 4
1 3

Sample Output

2 4

Hint

None

Source

alex4814

提交代码