#include <bits/stdc++.h>
using namespace std;
int N, M;
int sz[110000];
vector<pair<int, int> > pos[110000];
int gcd(int a, int b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
int calc(vector<pair<int, int> >& pos) {
  int n = pos.size();
  int r[50], cnt[50];
  int ans = 0;
  memset(cnt, 0, sizeof(cnt));
  for (int i = 0, j = 0; i < n; i++) {
    int m = sz[pos[i].first];
    int a = pos[i].second;
    for (int k = 1; k < 50; k++) {
      if (cnt[k] == 0) continue;
      int g = gcd(k, m);
      if ((a - r[k]) % g) {
        while (cnt[k]) {
          cnt[sz[pos[j].first]]--;
          j++;
        }
      }
    }
    ans = max(ans, i - j + 1);
    cnt[m]++;
    r[m] = a;
    if (i < n - 1 && pos[i].first + 1 < pos[i + 1].first) {
      while (j <= i) {
        cnt[sz[pos[j].first]]--;
        j++;
      }
    }
  }
  return ans;
}
int main() {
  scanf("%d%d", &N, &M);
  for (int i = 0; i < N; i++) {
    scanf("%d", &sz[i]);
    for (int j = 0; j < sz[i]; j++) {
      int x;
      scanf("%d", &x);
      pos[x].push_back(pair<int, int>(i, j));
    }
  }
  for (int i = 1; i <= M; i++) {
    printf("%d\n", calc(pos[i]));
  }
  return 0;
}
