#include <bits/stdc++.h>
using namespace std;
const int N = 100005;
int k[N];
vector<pair<int, int> > v[N];
long long exgcd(long long a, long long b, long long &x, long long &y) {
  if (!b) {
    x = 1;
    y = 0;
    return a;
  }
  long long x1, y1, g = exgcd(b, a % b, x1, y1);
  x = y1;
  y = x1 - a / b * y1;
  return g;
}
long long ti(long long a, long long b, long long p) {
  long long c = (long long)(1.0 * a * b / p + 1e-6) * p;
  return a * b - c;
}
struct equ {
  long long x, y;
};
struct seg {
  equ data;
  seg *lc, *rc;
} * rt, pool[N * 2], *tail = pool;
void build(seg *&rt, int l, int r) {
  rt = tail++;
  rt->data = {0, -1};
  if (l == r) return;
  int mid = l + r >> 1;
  build(rt->lc, l, mid);
  build(rt->rc, mid + 1, r);
}
equ mge(equ e, equ f) {
  if (!~e.y || !~f.y) return (equ){-1, -1};
  long long a = e.x, b = e.y, c = f.x, d = f.y, u, v, G = exgcd(b, d, u, v);
  equ g;
  if ((c - a) % G) return (equ){-1, -1};
  g.y = b / G * d;
  g.x = (ti(ti((c - a) / G, u, g.y), b, g.y) + a) % g.y;
  return g;
}
void mdf(seg *rt, int l, int r, int p, int x, int y) {
  if (l == r) {
    rt->data = {x, y};
    return;
  }
  int mid = l + r >> 1;
  if (p <= mid)
    mdf(rt->lc, l, mid, p, x, y);
  else
    mdf(rt->rc, mid + 1, r, p, x, y);
  rt->data = mge(rt->lc->data, rt->rc->data);
}
equ qry(seg *rt, int l, int r, int L, int R) {
  if (L <= l && r <= R) return rt->data;
  int mid = l + r >> 1;
  if (R <= mid) return qry(rt->lc, l, mid, L, R);
  if (L > mid) return qry(rt->rc, mid + 1, r, L, R);
  return mge(qry(rt->lc, l, mid, L, R), qry(rt->rc, mid + 1, r, L, R));
}
int main() {
  int n, m, i, j, x, y, t, ans, lst, l, r;
  scanf("%d%d", &n, &m);
  for (i = 1; i <= n; ++i) {
    scanf("%d", &k[i]);
    for (j = 0; j < k[i]; ++j) {
      scanf("%d", &x);
      v[x].push_back(make_pair(i, j));
    }
  }
  build(rt, 1, n);
  for (i = 1; i <= m; ++i) {
    ans = 0;
    for (j = t = 0; j < v[i].size(); j = t) {
      lst = v[i][j].first - 1;
      l = r = lst + 1;
      for (; t < v[i].size(); ++t) {
        x = v[i][t].first;
        y = v[i][t].second;
        if (x != lst + 1) break;
        mdf(rt, 1, n, x, y, k[x]);
        lst = x;
      }
      for (; l <= lst; ++l) {
        while (r <= lst && ~qry(rt, 1, n, l, r).y) ++r;
        ans = max(ans, r - l);
      }
    }
    printf("%d\n", ans);
  }
  return 0;
}
