Serval and Essay
题号:NC239332
时间限制:C/C++/Rust/Pascal 2秒,其他语言4秒
空间限制:C/C++/Rust/Pascal 256 M,其他语言512 M
64bit IO Format: %lld

题目描述

Serval is a new student in Japari Kindergarten.

There is an English course in the kindergarten. The teacher sets some writing tasks for students to improve their writing skills. Therefore, Serval has to complete an essay, in English.

You might know that in an essay, the author has to convince readers of several arguments by showing them evidence.

Serval have collected n available arguments numbered from 1 to n that can be written in his essay. For the i-th argument, Serval can conclude that i-th argument is true when the arguments numbered are all true. Specially, the i-th argument cannot be proven true by making conclusion when . It is guaranteed that for all i (), and when .

At the beginning of his essay, Serval will set exactly one argument from all the arguments as the argument basis, which is regarded as true. Starting with the argument basis, Serval will claim that some other arguments are true by making conclusions to complete his essay. It can be shown that for the i-th argument with , it can be true if and only if it is the argument basis.

Serval wants to maximize the number of true arguments in the essay, so he needs to set the argument basis optimally. However, as a kindergarten student, he cannot even find out the number of true arguments he can obtain.

Could you help him find out the answer?

输入描述:

Each test contains multiple test cases.

The first line contains an integer T () — the number of test cases.

For each test case:

The first line contains a single integer n () — the number of the available arguments.

For the i-th line in the following n lines, there is an integer k_i () followed by k_i integers () — the arguments required to make the conclusion for the i-th argument. It is guaranteed that for all i (), and when .

It is guaranteed that the sum of n in all the test cases does not exceed and the sum of k_i in all the test cases does not exceed .

输出描述:

For the i-th test case, print a line containing "" (without quotes), where i is the number of the test case starting from 1 and x is the answer to the test case, which is the maximum number of true arguments when setting the argument basis optimally.
示例1

输入

复制
3
4
0
1 1
2 1 2
2 2 3
5
1 3
1 1
1 2
1 5
4 1 2 3 4
7
0
2 1 4
1 2
1 3
2 3 4
1 1
2 5 6

输出

复制
Case #1: 4
Case #2: 3
Case #3: 4

备注:

For the first sample, Serval can set the 1-st argument as the argument basis to obtain 4 true arguments in the essay. The following process shows how Serval makes conclusions in his essay.

Set the 1-st argument as the argument basis, which is regarded as true.
Conclude that 2-nd argument is true because 1-st argument is true.
Conclude that 3-rd argument is true because both 1-st and 2-nd arguments are true.
Conclude that 4-th argument is true because both 2-nd and 3-rd arguments are true.