// uva 11825 Hacker's Crackdown
//
// 题目意思看了很久才看懂,有n台计算机,有n种服务,每台计算机上运行所有
// 的服务,并且其中有的计算机与某些计算机相互邻接,对于每台计算机,
// 你可以选择一项服务,停止这项服务,则与它邻接的计算机的该服务也停止了
// 你的目的是让经量多的服务完全瘫痪
//
// 换而言之,这个问题就是在n个集合中(p[1]....p[n])分成尽量多的组数,使得每组
// 的并集等于全集(即所有的n台电脑都停止)。。。
//
// 思路,就是状态压缩,因为n最大只有16。p[i]表示当前计算机和其邻接的计算机的
// 集合。
// 那么这n台计算机组合的情况有2的n次方。处理出所有组合情况下p的并集,计为s[i]
// 则f[s] = max(f[S-S0] + 1)
// {其中S0是S的子集,并且该种组合方式下s[S0]的集合等于全集((1<<n)-1)}
//
// 最后f[(1<<n)-1]就是我们要求的答案
//
// 这题主要是题目意思分析理解了很久,外加有高人相助
// 最后枚举子集的方法也是高人传授,这题真心的很巧妙
// 哎,继续练吧。。。
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>
#define ceil(a,b) (((a)+(b)-1)/(b))
#define endl '\n'
#define gcd __gcd
#define highBit(x) (1ULL<<(63-__builtin_clzll(x)))
#define popCount __builtin_popcountll
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
const long double PI = acos(-1.L);
template<class T> inline T lcm(const T& a, const T& b) { return a/gcd(a, b)*b; }
template<class T> inline T lowBit(const T& x) { return x&-x; }
template<class T> inline T maximize(T& a, const T& b) { return a=a<b?b:a; }
template<class T> inline T minimize(T& a, const T& b) { return a=a<b?a:b; }
const int maxn = 20;
int p[maxn];
int s[1<<maxn];
int f[1<<maxn];
int n;
void init(){
memset(f,0,sizeof(f));
int m;
for (int i=0;i<n;i++){
cin >> m;
p[i] = 1<<i;
int x;
for (int j=0;j<m;j++){
cin >> x;
p[i] |=(1<<x);
}
}
}
void solve(){
for (int S=0;S<(1<<n);S++){
s[S]=0;
for (int i=0;i<n;i++)
if (S&(1<<i))
s[S] |= p[i];
}
int all = (1<<n)-1;
for (int S=0;S<(1<<n);S++){
for (int S0=S;S0;S0 = (S0-1)&S){
if (s[S0]==all){
f[S] = max(f[S],f[S^S0]+1);
}
}
}
printf("%d\n",f[all]);
}
int main() {
//freopen("G:\\Code\\1.txt","r",stdin);
int kase = 1;
while(1){
cin >> n;
if (!n)
break;
printf("Case %d: ",kase++);
init();
solve();
}
return 0;
}