#include <bits/stdc++.h>
using namespace std;
const int N = 100000;
int n, m;
vector<long long> a[N];
long long len[N];
vector<int> ind[N];
vector<long long> p[N];
long long sparse[18][N][2];
long long gcd(long long a, long long b) {
  if (a == 0) return b;
  return gcd(b % a, a);
}
long long gcd2(long long a, long long b, long long& x, long long& y) {
  if (a == 0) {
    x = 0;
    y = 1;
    return b;
  }
  long long x1, y1;
  long long d = gcd2(b % a, a, x1, y1);
  x = y1 - (b / a) * x1;
  y = x1;
  return d;
}
long long count(long long p1, long long p2, long long k1, long long k2) {
  long long mn = gcd(k1, k2);
  long long mx = k1 / mn * k2;
  if (p1 == -1 || p2 == -1 || abs(p1 - p2) % mn != 0) return -1;
  k1 /= mn;
  k2 /= mn;
  long long q = (k2 / gcd(k1, k2) * k1 + (p2 - p1) / mn) % k2;
  long long x, y;
  gcd2(k1, k2, x, y);
  x = (x % k2 + k2) % k2;
  x = (x * q) % k2;
  return k1 * x * mn + p1;
}
bool solve(int l, int r) {
  long long curp = 0;
  long long curk = 1;
  for (int j = 18; j >= 0; j--) {
    if (l + (1 << j) > r) continue;
    curp = count(curp, sparse[j][l][0], curk, sparse[j][l][1]);
    if (curp == -1)
      break;
    else
      curk = curk / gcd(curk, sparse[j][l][1]) * sparse[j][l][1];
    l += 1 << j;
  }
  if (curp != -1) return true;
  return false;
}
int main() {
  srand(time(NULL));
  ios_base::sync_with_stdio(false);
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    cin >> len[i];
    for (int j = 0; j < len[i]; j++) {
      int x;
      cin >> x;
      x--;
      a[i].push_back(x);
      ind[x].push_back(i);
      p[x].push_back(j);
    }
  }
  for (int i = 0; i < m; i++) {
    int ans = 0;
    int l = 0, r = 0;
    for (int j = 1; j <= ind[i].size(); j++) {
      if (j != ind[i].size() && ind[i][j] == ind[i][j - 1] + 1) continue;
      r = j;
      for (int k = l; k < r; k++) {
        sparse[0][ind[i][k]][0] = p[i][k];
        sparse[0][ind[i][k]][1] = len[ind[i][k]];
      }
      int l1 = l, r1 = r;
      l = ind[i][l];
      r = ind[i][r - 1] + 1;
      for (int lg = 1; lg < 18; lg++) {
        for (int k = l; k < r; k++) {
          long long p1 = sparse[lg - 1][k][0];
          long long p2 = sparse[lg - 1][min(k + (1 << (lg - 1)), r - 1)][0];
          long long k1 = sparse[lg - 1][k][1];
          long long k2 = sparse[lg - 1][min(k + (1 << (lg - 1)), r - 1)][1];
          long long res = count(p1, p2, k1, k2);
          if (res == -1) {
            sparse[lg][k][0] = sparse[lg][k][1] = -1;
            continue;
          }
          sparse[lg][k][1] = k1 / gcd(k1, k2) * k2;
          sparse[lg][k][0] = res;
        }
      }
      l = l1;
      r = r1;
      int lst = l + 1;
      for (int k = l; k < r; k++) {
        while (lst < r && solve(ind[i][k], ind[i][lst] + 1)) lst++;
        ans = max(ans, lst - k);
      }
      l = j;
      if (l == ind[i].size()) break;
    }
    cout << ans << endl;
  }
  return 0;
}
