#include <bits/stdc++.h>
using namespace std;
vector<vector<pair<int, pair<int, int> > > > ad;
vector<vector<int> > fre(40);
int v[12] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37};
int sz[12] = {6, 4, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2};
long long int pro(long long int a, long long int b, long long int M) {
  if (b == 0 || a == 0) return 0;
  long long int d = a * b;
  if (d % a == 0 && d % b == 0 && d > 0)
    return d % M;
  else if (b % 2 == 0)
    return pro((a + a) % M, b / 2, M);
  else if (b % 2 == 1)
    return (a + pro((a + a) % M, b / 2, M)) % M;
}
long long int bit(long long int a, long long int b, long long int M) {
  long long int x = 1;
  a %= M;
  while (b > 0) {
    if (b & 1) x = pro(x, a, M);
    b = b >> 1;
    a = pro(a, a, M);
  }
  return x;
}
long long int join(long long int r1, long long int r2, long long int a1,
                   long long int a2, long long int p1, long long int p2) {
  long long int b1 = bit(r2, p1 - 1, r1);
  long long int b2 = bit(r1, p2 - 1, r2);
  long long int y =
      pro(pro(a1, b1, r1), r2, r1 * r2) + pro(pro(a2, b2, r2), r1, r1 * r2);
  return y % (r1 * r2);
}
long long int gcd(long long int a, long long int b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
int ans(int k) {
  int n, m = 0, l, i = 0, j, s = ad[k].size(), z;
  long long int lcm, mod, phi, a, b, g, p, q, r, y;
  while (i < s) {
    j = i;
    while (j < s - 1 && ad[k][j + 1].first - ad[k][j].first == 1) j++;
    for (z = 0; z < 12; z++) {
      for (n = 1; n < sz[z]; n++) fre[v[z]][n] = 0;
    }
    l = 0, n = 0;
    lcm = 1, mod = 0, phi = 1;
    while (i <= j) {
      a = ad[k][i].second.second, r = ad[k][i].second.first;
      g = gcd(lcm, a);
      if (mod % g == r % g) {
        b = a, q = a, l++;
        for (z = 0; z < 12; z++) {
          if (b % v[z] == 0) {
            p = 0, q -= (q / v[z]);
            while (b % v[z] == 0) p++, b /= v[z];
            fre[v[z]][p]++;
          }
        }
        y = join(lcm / g, a / g, (mod - mod % g) / g, (r - r % g) / g, phi, q),
        b = a;
        mod = r % g + y * g, n = max(n, l), i++, lcm /= g, lcm *= a, phi = lcm;
        for (z = 0; z < 12; z++) {
          if (lcm % v[z] == 0) phi -= (phi / v[z]);
        }
      } else {
        a = ad[k][i - l].second.second, b = a, l--;
        for (z = 0; z < 12; z++) {
          if (b % v[z] == 0) {
            p = 0, q = v[z];
            while (b % v[z] == 0) p++, b /= v[z], q *= v[z];
            fre[v[z]][p]--;
            if (fre[v[z]][p] == 0 && lcm % q > 0) {
              while (fre[v[z]][p] == 0) p--, lcm /= v[z];
            }
          }
        }
        phi = lcm, mod %= lcm;
        for (z = 0; z < 12; z++) {
          if (lcm % v[z] == 0) phi -= (phi / v[z]);
        }
      }
    }
    i = j + 1, m = max(m, n);
  }
  return m;
}
int main() {
  int n, m, i, j, k, x, s;
  scanf("%d", &n), scanf("%d", &m);
  ad.resize(m + 1);
  for (i = 0; i < 12; i++) fre[v[i]].resize(sz[i], 0);
  for (i = 0; i < 12; i++) fre[v[i]][0] = 1000000;
  for (i = 0; i < n; i++) {
    scanf("%d", &k);
    for (j = 0; j < k; j++)
      scanf("%d", &x), ad[x].push_back(make_pair(i, make_pair(j, k)));
  }
  for (i = 1; i <= m; i++) printf("%d\n", ans(i));
}
