The students in Kim¡¯s class did a popularity vote to determine who were popular in the class. Each student was asked to write down the ID numbers of at most three students, except himself/herself, whom he or she liked. After the vote was over and popular students were chosen, Kim, looking at the vote result, was curious to solve the following math question: What was the largest core? A set of students is called a core if every student in the set * voted, * liked some students in it but no one outside it, and * was liked by some one in it. More formally, each student will be represented by his or her student ID number from {1, 2, . . . ,N}, where the class has N students. For example, the table below shows the result of a vote by 12 students in Kim¡¯s class.

The input consists of T test cases. The number of test cases (T) is given on the first line of the input file. The first line of each test case contains two integers N and M, where N (1 < = N < = 10000) is the number of students in the class, and M is the number of students who voted. Each of the following M lines is to begin with an integer i representing a student ID number in {1, 2, . . . ,N}, which is to be followed by an integer Ni (1 < = Ni < = 3) Ni representing the number of students written down by student i, which is to be followed in turn by a sequence of Ni integers representing the ID numbers written down by student i.

Print exactly one line for each test case. The line is to contain an integer that is the size of the largest core. The following shows sample input and output for two test cases.

1 12 9 1 2 4 8 2 3 9 12 3 4 1 8 5 2 1 6 6 1 5 7 1 8 8 1 1 10 3 8 7 6 12 1 10Sample output5