2017/4/8
// 坑点:不一定第一行就是根及其子结点,所以得先存储数据后遍历
// 开始我读入数据就确定了其层数,导致三个测试点过不了。
#include <iostream>
#include <map>
#include <vector>
using namespace std;
map<int, vector<int> > tree;
int Level[105];
int cnt = 0;
void dfs(int id, int level){
if(tree[id].empty()){
Level[level]++;
if(cnt < level)
cnt = level;
return ;
}
vector<int>::iterator it;
for(it = tree[id].begin(); it != tree[id].end(); it++){
dfs(*it, level+1);
}
}
int main(){
int n, m;
cin >> n >> m;
int id, ssum, son;
for(int i = 0; i < m; i++){
cin >> id >> ssum;
for(int j = 0; j < ssum; j++){
cin >> son;
tree[id].push_back(son);
}
}
dfs(1, 0);
//cout << "cnt : " << cnt << endl;
for(int i = 0; i <= cnt; i++){
if(i)
cout << ' ';
cout << Level[i];
}
cout << endl;
return 0;
}