1 /**************************************************************
2 Problem: 1688
3 User: child
4 Language: C++
5 Result: Accepted
6 Time:140 ms
7 Memory:1456 kb
8 ****************************************************************/
9
10 #include<cstdio>
11 #include<iostream>
12 #define maxn 10100
13 using namespace std;
14
15 int n,d,k,num,tot,sick[maxn],DP[1<<15],ret;
16
17 bool check(int code){
18 int cnt = 0;
19 for(int i = 0;i < d;i++){
20 if((code>>i)&1) cnt++;
21 }return (cnt<=k)?1:0;
22 }
23
24 int main(){
25 scanf("%d%d%d",&n,&d,&k);
26
27 tot = (1<<d)-1;
28
29 for(int i = 1;i <= n;i++){
30 scanf("%d",&num);
31 int cnt;
32 for(int j = 1;j <= num;j++){
33 scanf("%d",&cnt);
34 sick[i] |= (1<<(cnt-1));
35 }
36 }
37
38 for(int i = 1;i <= n;i++)
39 for(int j = tot;j >= 0;j--)
40 DP[sick[i]|j] = max(DP[sick[i]|j],DP[j]+1);
41
42 for(int i = 0;i <= tot;i++) if(check(i)) ret = max(ret,DP[i]);
43
44 printf("%d",ret);
45
46 return 0;
47 }