#include <bits/stdc++.h>
using namespace std;
const int maxn = 500005;
int fa[maxn];
int sum[maxn];
int n, m;
int find(int x) {
  if (fa[x] == x) return x;
  int f = find(fa[x]);
  return fa[x] = f;
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) fa[i] = i, sum[i] = 1;
  for (int tt = 1; tt <= m; tt++) {
    int nn, x, y;
    scanf("%d", &nn);
    for (int i = 1; i <= nn; i++) {
      scanf("%d", &y);
      if (i == 1) {
        x = y;
        continue;
      }
      int xx = find(x), yy = find(y);
      if (xx != yy) {
        fa[yy] = xx;
        sum[xx] += sum[yy];
      }
    }
  }
  for (int i = 1; i <= n - 1; i++) printf("%d ", sum[find(i)]);
  printf("%d\n", sum[find(n)]);
}
