#include <bits/stdc++.h>
using namespace std;
int g[45][45];
int last[100005], fir[100005];
int n, m, k;
int ans[100005];
int wz[100005][45][2];
int gcd(int x, int y) { return y == 0 ? x : gcd(y, x % y); }
int main() {
  for (int i = 1; i <= 40; i++)
    for (int j = 1; j <= 40; j++) g[i][j] = gcd(i, j);
  memset(last, 63, sizeof(last));
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &k);
    for (int j = 1; j <= k; j++) {
      int x;
      scanf("%d", &x);
      if (last[x] != i - 1) {
        fir[x] = i;
        last[x] = i;
        ans[x] = (((ans[x]) > (1)) ? ans[x] : 1);
        wz[x][k][0] = i;
        wz[x][k][1] = j;
        continue;
      }
      last[x] = i;
      for (int l = 1; l <= 40; l++) {
        if (wz[x][l][0] < fir[x]) continue;
        if ((j - wz[x][l][1]) % g[k][l] != 0) fir[x] = wz[x][l][0] + 1;
      }
      wz[x][k][0] = i;
      wz[x][k][1] = j;
      ans[x] = (((ans[x]) > (i - fir[x] + 1)) ? ans[x] : i - fir[x] + 1);
    }
  }
  for (int i = 1; i <= m; i++) printf("%d\n", ans[i]);
  return 0;
}
