#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
const int MAXN=1001;
int fa[MAXN];
struct Node{
int id;
int hobby[MAXN];
Node(){
id=0;
hobby[MAXN]={};
}
}node[MAXN];
int getfather(int x){
int a=x;
while(x!=fa[x]){
x=fa[x];
}
while(a!=fa[a]){
int z=a;
a=fa[a];
fa[z]=x;
}
return x;
}
void _union(int a,int b){
int aa=getfather(a);
int bb=getfather(b);
if(aa!=bb) fa[aa]=bb;
}
int main()
{
#ifndef ONLINE_JUDGE
freopen("in.txt","r",stdin);
#endif
int n;
cin>>n;
for(int i=0;i<MAXN;i++){
fa[i]=i;
}
bool hob[MAXN]={false};
for(int i=0;i<n;i++){
node[i].id=i+1;
int k;
scanf("%d: %d ",&k,&node[i].hobby[0]);
hob[node[i].hobby[0]]=true;
for(int j=1;j<k;j++){
cin>>node[i].hobby[j];
hob[node[i].hobby[j]]=true;
_union(node[i].hobby[j],node[i].hobby[0]);
}
}
vector<Node> ppp[MAXN];
int familycnt=0;
bool root[MAXN]={false};
for(int i=0;i<MAXN;i++){
if(hob[i]==true){
root[getfather(i)]=true;
}
}
for(int i=0;i<MAXN;i++){
if(root[i]==true) familycnt++;
}
cout<<familycnt<<endl;
for(int i=0;i<n;i++){
ppp[getfather(node[i].hobby[0])].push_back(node[i]);
}
vector<int> temp;
for(int i=0;i<MAXN;i++){
if(ppp[i].size()!=0){
temp.push_back(ppp[i].size());
}
}
sort(temp.begin(),temp.end());
for(int i=temp.size()-1;i>=0;i--){
if(i==temp.size()-1) cout<<temp[i];
else
cout<<' '<<temp[i];
}
return 0;
}