Alternative Accounts
Time limit2sMemory limit512 MB
Given up to 4 contests and the accounts in each, find the fewest people who can own all accounts, where two accounts in the same contest need different owners.
- Level
Medium6 of 10
- Topics
- Bit manipulation, Graph, Brute force
- Solved
- No attempts yet
Problem
Everybody knows that jiry_2 = Syloviaely.
There are different accounts on the website, and some of them competed in the recent contests. Mike suspects that there are many alternative accounts, meaning two or more accounts owned by the same person.
Two axioms are believed by everyone:
- Nobody can use two different accounts in one contest at the same time.
- Nobody shares an account. 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.
Input
The first line contains an integer (), the number of test cases. Each test case is described as follows.
The first line contains two integers and (, ).
Each of the following lines starts with an integer (), followed by distinct integers (), the accounts that took part in that contest.
Some accounts may not take part in any contest.
It is guaranteed that .
Output
For each test case, print one line with one integer: the answer.