#include <bits/stdc++.h>
using namespace std;
int read() {
  int s = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') s = s * 10 + ch - '0', ch = getchar();
  return s * f;
}
__int128 exgcd(__int128 a, __int128 b, __int128 &x, __int128 &y) {
  if (!b) return x = 1, y = 0, a;
  __int128 g = exgcd(b, a % b, y, x);
  y -= a / b * x;
  return g;
}
void calc(__int128 p, __int128 a, __int128 q, __int128 b, __int128 &m,
          __int128 &c) {
  if (a == -1 || b == -1) return c = -1, void();
  if (b < a) swap(b, a), swap(q, p);
  __int128 x, y, g = exgcd(p, q, x, y);
  if (x < 0) x += q, y -= p;
  if (y < 0) y += p, x -= q;
  if ((b - a) % g) return c = -1, void();
  m = p / g * q;
  __int128 coe = (a - b) / g;
  x = coe * x % q;
  c = a - p * x;
  c = (c % m + m) % m;
}
struct st {
  __int128 m[200010], b[200010], fm[20][200010], fb[20][200010];
  int n, lg[200010];
  void build() {
    for (int i = 2; i <= n; i++) lg[i] = lg[i >> 1] + 1;
    for (int i = 0; i < n; i++) fm[0][i] = m[i], fb[0][i] = b[i];
    for (int i = 1; i <= lg[n]; i++)
      for (int j = 0; j + (1 << i) - 1 < n; j++)
        calc(fm[i - 1][j], fb[i - 1][j], fm[i - 1][j + (1 << i - 1)],
             fb[i - 1][j + (1 << i - 1)], fm[i][j], fb[i][j]);
  }
  __int128 query(int l, int r) {
    int k = lg[r - l + 1];
    __int128 m, b;
    calc(fm[k][l], fb[k][l], fm[k][r - (1 << k) + 1], fb[k][r - (1 << k) + 1],
         m, b);
    return b;
  }
} w;
int n, m, k[200010];
vector<pair<int, int> > pos[200010];
int main() {
  n = read(), m = read();
  for (int i = 1; i <= n; i++) {
    k[i] = read();
    int x;
    for (int j = 0; j < k[i]; j++)
      x = read(), pos[x].push_back(make_pair(i, j));
  }
  for (int i = 1; i <= m; i++) {
    w.n = pos[i].size();
    int ans = 0;
    for (int j = 0; j < pos[i].size(); j++)
      w.m[j] = k[pos[i][j].first], w.b[j] = pos[i][j].second;
    w.build();
    int d = 1;
    for (int j = 0, z; j < pos[i].size(); j = z) {
      int cc = pos[i][j].first;
      for (z = j; z < pos[i].size(); z++)
        if (pos[i][z].first != cc)
          break;
        else
          cc++;
      for (int l = j; l < z; l++) {
        while (l + d < z && w.query(l, l + d) != -1) d++;
        ans = max(ans, d);
      }
    }
    printf("%d\n", ans);
  }
  return 0;
}
