Input:
standard input
Output: standard output
Time Limit: 5 seconds
It happens that one person has duplicates of a certain sticker.
Everyone trades duplicates for stickers he doesn't possess. Since all
stickers have the same value, the exchange ratio is always 1:1.
But Bob is clever: he has realized that in some cases it is good for
him to trade one of his duplicate stickers for a sticker he already
possesses.
Now assume, Bob's friends will only exchange stickers with Bob, and
they will give away only duplicate stickers in exchange with different
stickers they don't possess.
Can you help Bob and tell him the maximum number of different stickers
he can get by trading stickers with his friends?
Input
The first
line of input contains the number of cases T (T<=20).
The first line of each case contains two integers n and m
(2<=n<=10, 5<=m<=25). n is the number of people involved
(including Bob), and m is the number of different stickers available.
The next n lines describe each person's stickers; the first of these
lines describes Bob's stickers.
The i-th of these lines starts with a number ki<=50 indicating how
many stickers person i has.
Then follows ki numbers between 1 and
m indicating which stickers
person i possesses.
Output
For each case, print the test case number together with the maximum number of different stickers Bob can get.
Sample Input
2
2 5
6 1 1 1 1 1 1
3 1 2 2
3 5
4 1 2 1 1
3 2 2 2
5 1 3 4 4 3
Sample
Output
Case #1: 1
Case #2: 3
Problem setter: Adrian Kuegel