#include <bits/stdc++.h>
using namespace std;
const int mxn = 100006;
void maxto(int &a, int b) { a = max(a, b); }
int n, m;
set<int> s[mxn];
vector<int> a[mxn];
map<int, int> p[mxn];
int rem[41];
int cnt[41];
vector<int> d[41];
int ans[mxn];
void add(int n, int x) {
  for (auto i : d[n]) {
    if (cnt[i])
      ++cnt[i];
    else {
      rem[i] = x % i;
      cnt[i] = 1;
    }
  }
}
bool tadd(int n, int x) {
  for (auto i : d[n])
    if (cnt[i] && rem[i] != x % i) return false;
  return true;
}
void dec(int n, int x) {
  for (auto i : d[n]) {
    --cnt[i];
  }
}
int main() {
  for (int i = 2; i <= 40; ++i)
    for (int j = i; j <= 40; j += i) d[j].push_back(i);
  cin >> n >> m;
  for (int i = 1; i <= n; ++i) {
    int l;
    scanf("%d", &l);
    for (int j = 0; j < l; ++j) {
      int t;
      scanf("%d", &t);
      a[i].push_back(t);
      s[t].insert(i);
      p[i][t] = j;
    }
  }
  for (int i = 1; i <= m; ++i)
    if (!s[i].empty()) {
      memset(rem, 0, sizeof rem);
      memset(cnt, 0, sizeof cnt);
      int l = 0, r = -1;
      for (auto j : s[i]) {
        if (j != r + 1) {
          while (l <= r) {
            dec(a[l].size(), p[l][i]);
            ++l;
          }
          add(a[j].size(), p[j][i]);
          l = r = j;
          maxto(ans[i], r + 1 - l);
        } else {
          while (!tadd(a[j].size(), p[j][i])) {
            dec(a[l].size(), p[l][i]);
            ++l;
          }
          add(a[j].size(), p[j][i]);
          ++r;
          maxto(ans[i], r + 1 - l);
        }
      }
    }
  for (int i = 1; i <= m; ++i) printf("%d\n", ans[i]);
  return 0;
}
