#include<cstdio>
#include<algorithm>
using namespace std;
const int N=1<<16;
int n,d,k,a[N],cnt[N];
int main()
{
freopen("disease.in","r",stdin);
freopen("disease.out","w",stdout);
scanf("%d%d%d",&n,&d,&k);
for (int i=1;i<=n;i++){
int x=0,y,p;
scanf("%d",&p);
for (int i=1;i<=p;i++){
scanf("%d",&y);
x|=1<<(y-1);
}
a[x]++;
}
for (int i=0;i<d;i++)
for (int j=0;j<(1<<d);j++)
if (j>>i&1) a[j]+=a[j^(1<<i)];
int ans=0;
for (int i=0;i<(1<<d);i++){
cnt[i]=cnt[i>>1]+(i&1);
if (cnt[i]<=k) ans=max(ans,a[i]);
}
printf("%d\n",ans);
return 0;
}