Problem Description
Street Fighter is a popular Fighting game. In the game, you could choose many roles to fight.
Each role has some models, in different model the role has different super skill. Such as Ryu, he has two model -- "Metsu Hadoken" and "Metsu Shoryuken". In "Metsu Hadoken" model, Ryu could beat Chun-Li easyly and in "Metsu Shoryuken" he could beat Ken.
Giving the information of which role in which model could beat which role in which model. Your task is choosing minimum roles in certain model to beat other roles in any model.(each role could only be chosen once)
Input
The first line is a number T(1<=T<=30), represents the number of case. The next T blocks follow each indicates a case.
The first line of each case contains a integers N(2<=N<=25), indication the number of roles. (roles numbered from 0 to N - 1).
Then N blocks follow, each block contain the information of a role.
The first of each block contains a integer M(1<=M<=2), indication the number of model of this role.(models numbered from 0 to M - 1)
Then M lines follow, each line contain a number K(1<=K<=10), then K pairs integers(role id and model id) follow, indicating the current role in this model could beat that role in such model.
Output
For each case, output the number of case and the minimum roles have to choose to reach the goal.(as shown in the sample output)
Sample Input
2
2
2
1 1 0
1 1 1
2
1 0 0
1 0 1
4
2
2 1 0 1 1
1 2 0
2
2 3 0 0 1
1 2 0
2
2 0 0 0 1
1 1 0
2
2 2 0 2 1
1 1 0
Sample Output
Case 1: 2
Case 2: 2