#include <bits/stdc++.h>
using namespace std;
const long long N = 200005;
long long n, m, lat[N];
inline long long read() {
  long long x = 0, ff = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') ff = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = (x << 1) + (x << 3) + (ch ^ 48);
    ch = getchar();
  }
  return x * ff;
}
struct node {
  long long id, k, len;
};
vector<node> a[N];
long long num[N], ban[N];
inline long long gcd(long long x, long long y) {
  if (y == 0) return x;
  return gcd(y, x % y);
}
bool check(long long k1, long long b1, long long k2, long long b2) {
  if (k1 == k2) return b1 == b2;
  return (b2 - b1) % gcd(k1, k2) == 0;
}
signed main() {
  n = read();
  m = read();
  for (long long i = 1; i <= n; i++) {
    long long ki;
    ki = read();
    for (long long j = 1; j <= ki; j++) {
      long long x;
      x = read();
      a[x].push_back((node){i, j - 1, ki});
    }
  }
  for (long long x = 1; x <= m; x++) {
    long long l = 0, ans = 0;
    for (long long i = 1; i <= 40; i++) num[i] = ban[i] = lat[i] = 0;
    long long Len = a[x].size();
    for (long long i = 0; i < Len; i++) {
      if (i && a[x][i].id != a[x][i - 1].id + 1) {
        while (l < i) {
          num[a[x][l].len]--;
          l++;
        }
      }
      for (long long j = 1; j <= 40; j++) {
        if (!num[j]) continue;
        if (!check(j, ban[j], a[x][i].len, a[x][i].k)) {
          while (l <= lat[j]) num[a[x][l++].len]--;
        }
      }
      num[a[x][i].len]++;
      ban[a[x][i].len] = a[x][i].k;
      lat[a[x][i].len] = i;
      ans = max(ans, i - l + 1);
    }
    printf("%lld\n", ans);
  }
  return 0;
}
