#include <bits/stdc++.h>
using namespace std;
int related(vector<int> &a,vector<int> &b){
int count=0;
int i=0,j=0;
while(i<a.size()&&j<b.size()){
if(a[i]==b[j])
count++,i++,j++;
else if(a[i]<b[j])
i++;
else
j++;
}
return count;
}
int main(){
ios::sync_with_stdio(0);
cin.tie(NULL);
int n,k;
cin>>n>>k;
vector<int> a[300];
bitset<301> vis;
for(int i=0;i<n;i++){
int p;
cin>>p;
while(p--){
int tmp;
cin>>tmp;
a[i].push_back(tmp);
}
sort(a[i].begin(),a[i].end());
}
queue<int> b;
b.push(0);
vis[0]=1;
while(!b.empty()){
int i=b.front();
b.pop();
for(int j=0;j<n;j++){
if(!vis[j]&&related(a[i],a[j])>=k)
b.push(j),vis[j]=1;
}
}
cout<<vis.count()<<'\n';
}
Comments
Post a Comment