#include<cstdio>
#include<cstring>
#include<algorithm>
#define N 1005
using namespace std;
int father[N];
int isRoot[N];
int course[N];
int findFather(int x){
    if(father[x] == x) return x;
    else{
        int tp = findFather(father[x]);
        father[x] = tp;
        return tp;
    }
}
void Union(int a,int b){
    int faA = findFather(a);
    int faB = findFather(b);
    if(faA != faB)
        father[faA] = faB;
}
void init(int n){
    for(int i = 1;i <= n;i++){
        father[i] = i;
        course[i] = 0;
        isRoot[i] = 0;
    }
}

bool cmp(int a,int b){
    return a > b;
}

int main(){
    int n;
    scanf("%d",&n);
    init(n);
    for(int i = 1;i <= n;i++){
        int k,h;
        scanf("%d:",&k);
        while(k--){
            scanf("%d",&h);
            if(course[h] == 0){
                course[h] = i;
            }
            Union(i,findFather(course[h]));
        }   
    }
    int ans = 0;
    for(int i = 1;i <= n; i++){
        isRoot[findFather(i)]++;
    }
    for(int i = 1;i <= n; i++){
        if(isRoot[i] != 0)
        ans++;
    }
    sort(isRoot,isRoot+n+1,cmp);    
    printf("%d\n",ans);
    for(int i = 0;i < ans; i++){
        if(isRoot[i]){
            printf(i==0?"%d":" %d",isRoot[i]);
        }

    }
    return 0;
}