Limits 1s, 512 MB

This problem is very easy. As my mood is not so good, I will not elaborate the statement unnecessarily. In this problem you will be given N sets. Each of them will contain some distinct integer numbers. You have to form a new set using some chosen sets from given sets in a way such that there is no common element among the chosen sets and the number of total elements in the newly formed set is the maximum possible.

Input

In first line there will be an integer T, denoting the number of testcases.
In the first line of each test case there will be an integer N, denoting the number of sets. Then each of the next N lines will contain some integers. The first integer is Mi, the number of elements in ith set. And then there will be Mi space separated distinct integers A1, A2, ....Aj, ..., AMi denoting the elements of the ith set.
summation of Mi over all testcases will not exceed 3×106

Constraints:
Subtask 1 (10 points):
1 ≤ T ≤ 10
1 ≤ N ≤ 10
1 ≤ Mi ≤ 100
1 ≤ Aj ≤ 1000

Subtask 2 (90 Points):
1 ≤ T ≤ 10
1 ≤ N ≤ 20
1 ≤ Mi ≤ 100000
1 ≤ Aj ≤ 1018

Output

For each test case, print the size of the newly formed set.

Sample

InputOutput
1
3
2 1 2
2 2 3
2 1 3
2

Submit

Login to submit.

Statistics

22% Solution Ratio
developer.spyderEarliest, Jun '20
mbsabbirr127Fastest, 0.2s
Matrix.codeLightest, 20 MB
Tahmid690Shortest, 1546B
Toph uses cookies. By continuing you agree to our Cookie Policy.