#include"bits/stdc++.h"
using namespace std;
vector<int> table[100];
int vis[100];
int v_cnt[100];
int n, noln;
int ceng[100];
int ans[100];
int node_vis[100];
void ans_set(int node, int c){
ceng[node] = c;
int n = table[node].size();
for(int i = 0; i < n; ++i)
ans_set(table[node][i], c + 1);
}
int main(){
memset(vis, 0, 400);
memset(v_cnt, 0, 400);
memset(ceng, 0, 400);
memset(ans, 0, 400);
memset(node_vis, 0 ,400);
cin >> n >> noln;
if(1 == n){
cout << "1";
return 0;
}
for(int i = 0; i < noln; ++i){
int a;
cin >> a;
int cn;
cin >> cn;
vis[a] = node_vis[a] = 1;
for(int j = 0; j < cn; ++j){
int tp;
cin >> tp;
table[a].push_back(tp);
v_cnt[tp]++;
node_vis[tp] = 1;
}
}
int root;
for(int i = 0; i < 100; ++i){
if(vis[i] == 1 && v_cnt[i] == 0){
root = i;
break;
}
}
ans_set(root, 0);
int max_c = -1;
for(int i = 0; i < 100; ++i){
if(node_vis[i] && table[i].size() == 0){
max_c = max(max_c, ceng[i]);
ans[ceng[i]]++;
}
}
for(int i = 0; i <= max_c; ++i){
if(i) cout << " ";
cout << ans[i];
}
}
11-15
1048