In the ancient myth, Invoker is a hero who can summon elements such as fire, ice, lightning (and much, much more) into his command. Summoning element isn't as easy as it seems, though. To summon elements, one must use one of the ancient spells from "the Book of Qua, Wex and Exort". However, a spell can (and must) summon forth several elements at once, where the rules are all recorded in the book. There are N elements in total, and there are 2N possible spells, each corresponding to summoning a subset of the N elements.
For example, a spell "Quasdo-Wexiarius" may summon the Ice and Lightning element all at once, and Invoker may not choose to summon only one of them. There is one more complication, the manipulation of elements must be accurate, so too much or too little of an element makes it simply vanish due to imbalance of energy flow. So, summoning some particular element when it is already present cause it to disappear. For example, if Invoker has the Ice elemental in presence and uses the "Quasdo-Wexiarius" spell, the Ice element will vanish, and the Lightning element will emerge.
Now, Invoker wants to perform several ritual. Each ritual requires particular (no more, no less) elements to accomplish. For example, the ritual to summon a meteor may need the fire and lightning element simultaneously, and no other element may be present.
Given all the rituals Invoker wishes to perform (in terms of what elements are needed), decide at least how many spells Invoker must learn from the book, so that he could perform all the rituals by combining spells.
The first line contains one integer T(T<=30) -- number of tests.
the first line of each test contains two number M, N (M is the number of rituals Invoker wishes to perform).
In each of following M line, the i-th line contain numi+1 integer. The first number is the number of elements the i-th ritual needs, and the following numi integers denote the id of these required elements (which are numbered from 0 to N-1).
In each test,
1<=M<=500
1<=N<=10000
For each testcase, output the minimum number of spells Invoker must learn from the book.
2 3 3 2 0 1 2 0 2 2 1 2 3 100 1 1 1 10 1 99
2 3
Migrated from old NTUJ.
No. | Testdata Range | Score |
---|