#include<bits/stdc++.h>
using namespace std;
const int Max=1010;
int father[Max];
int height[Max];
int n,course[Max],isroot[Max];
void Initial() {
for(int i=1; i<=n; i++) {
father[i]=i;
height[i]=0;
}
}
int Find(int x) {
if(x!=father[x]) {
father[x]=Find(father[x]);
}
return father[x];
}
void Union(int x,int y) {
x=Find(x);
y=Find(y);
if(x!=y) {
if(height[x]>height[y]) {
father[y]=x;
} else if(height[y]>height[x]) {
father[x]=y;
} else {
father[x]=y;
height[y]++;
}
}
return ;
}
int main() {
int k,x;
scanf("%d",&n);
Initial();
for(int i=1; i<=n; i++) {
scanf("%d:",&k);
for(int j=0; j<k; j++) {
scanf("%d",&x);
if(course[x]==0) {
course[x]=i;
}
Union(i,Find(course[x]));
}
}
for(int i=1; i<=n; i++) {
isroot[Find(i)]++;
}
int component=0;
for(int i=1; i<=n; i++) {
if(isroot[i]!=0) {
component++;
}
}
printf("%d\n",component);
sort(isroot+1,isroot+n+1,greater<int>());
for(int i=1; i<=component; i++) {
printf("%d",isroot[i]);
if(i<component) printf(" ");
}
return 0;
}