#include <bits/stdc++.h>
using namespace std;
struct $ {
  $() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
  }
} $;
const int N = 100002;
int n, m;
vector<int> a[N];
vector<int> pri[N];
vector<int> ans;
vector<tuple<int, int>> where[N];
const int NPR = 20;
int primes[NPR] = {
    2, 3, 4, 5, 7, 8, 9, 11, 13, 16, 17, 19, 23, 25, 27, 29, 31, 32, 36, 37,
};
int mod[NPR], cnt[NPR];
int main() {
  cin >> n >> m;
  for (int i = 0; i < n; ++i) {
    int k;
    cin >> k;
    a[i].resize(k);
    for (int j = 0; j < k; ++j) {
      cin >> a[i][j];
      where[a[i][j]].emplace_back(i, j);
    }
    for (int j = 0; j < NPR; ++j)
      if (k % primes[j] == 0) pri[i].emplace_back(j);
  }
  ans.resize(m + 1);
  for (int i = 0; i < n; ++i) {
    const auto &v = a[i];
    int ki = int(v.size());
    for (int j = 0; j < ki; ++j) {
      int x = v[j];
      if (ans[x]) continue;
      ans[x] = 1;
      auto wit = begin(where[x]);
      for (int start = -2, stop = -2; wit != end(where[x]); ++wit) {
        int row, off;
        tie(row, off) = *wit;
        if (row != stop) {
          start = stop = row;
          fill(begin(cnt), end(cnt), 0);
        }
        for (int prq : pri[stop]) {
          if (mod[prq] == off % primes[prq]) {
            ++cnt[prq];
          } else {
            for (; cnt[prq]; ++start) {
              for (int prp : pri[start]) --cnt[prp];
            }
            cnt[prq] = 1;
            mod[prq] = off % primes[prq];
          }
        }
        ++stop;
        ans[x] = max(ans[x], stop - start);
      }
    }
  }
  for (int i = 1; i <= m; ++i) {
    cout << ans[i] << '\n';
  }
  return 0;
}
