시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
2 초 512 MB 5 4 4 80.000%

문제

Everybody knows that jiry_2 = Syloviaely.

There are n different accounts on the website, and some of them competed in the recent k contests. However, Mike suspects that there are lots of alternative accounts: two or more accounts owned by the same person.

There are axioms believed by everyone:

  • Nobody can use two different accounts in one contest simultaneously.
  • Nobody shares an account, which means that each account can only be owned by one person.

So, a set of accounts may be owned by the same person if no two of them took part in the same contest.

Mike wants to know the minimum possible number of different people behind the given list of accounts.

입력

The first line contains an integer T (1 ≤ T ≤ 105) indicating the number of test cases. For each test case:

The first line contains two integers n, k (1 ≤ n ≤ 105, 1 ≤ k ≤ 4).

Each of the following k lines contains an integer m (1 ≤ m ≤ n) first, followed by m distinct integers xi (1 ≤ xi ≤ n) indicating the accounts participating in the contest.

Some accounts may not participate in any contests.

It is guaranteed that Σn ≤ 5 · 105.

출력

For each test case, output one line with one integer: the answer.

예제 입력 1

1
5 3
2 1 2
3 2 3 4
4 4 5 1 2

예제 출력 1

4