#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <vector>
#include <queue>
using namespace std;
struct Node{
int layer;
vector<int> son;
}node[110];
int N, M;
int leaf[110], maxlay = -1;
void dfs(int index){
if(node[index].son.size() == 0){
maxlay = max(maxlay, node[index].layer);
leaf[node[index].layer]++;
return;
}else{
for(int i = 0; i < node[index].son.size(); i++){
int temp = node[index].son[i];
node[temp].layer = node[index].layer + 1;
dfs(temp);
}
}
}
int main(){
scanf("%d %d", &N, &M);
if(N == 0) return 0;
memset(leaf, 0, sizeof(leaf));
int no, k, x;
for(int i = 0; i < M; i++){
scanf("%d %d", &no, &k);
for(int j = 0; j < k; j++){
scanf("%d", &x);
node[no].son.push_back(x);
}
}
node[1].layer = 1;
dfs(1);
printf("%d", leaf[1]);
for(int i = 2; i <= maxlay; i++){
printf(" %d", leaf[i]);
}putchar('\n');
return 0;
}