#include <bits/stdc++.h>
using namespace std;
struct req {
  int pos;
  vector<pair<int, int> > mods;
};
struct op {
  int pos, mod, val;
};
map<int, vector<req> > data;
int p[] = {2, 4, 8, 16, 32, 3, 9, 27, 5, 25, 7, 11, 13, 17, 19, 23, 29, 31, 37};
int solve(vector<req> arr) {
  int ans = 0;
  int l = 0;
  vector<int> curmod(19, -1), last(19, -2);
  for (int r = 0; r < arr.size(); ++r) {
    if (r > 0 && arr[r].pos - arr[r - 1].pos > 1) l = r;
    for (int i = 0; i < arr[r].mods.size(); ++i) {
      int p = arr[r].mods[i].first, m = arr[r].mods[i].second;
      if (curmod[p] != m) {
        l = max(l, last[p] + 1);
        curmod[p] = m;
      }
      last[p] = r;
    }
    ans = max(ans, r - l + 1);
  }
  return ans;
}
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < n; ++i) {
    int k;
    scanf("%d", &k);
    vector<int> arr(k);
    for (int j = 0; j < k; ++j) scanf("%d", &arr[j]);
    vector<int> primes;
    for (int j = 0; j < 19; ++j)
      if (k % p[j] == 0 > 1) primes.push_back(j);
    for (int j = 0; j < k; ++j) {
      req cur;
      cur.pos = i;
      for (int pi : primes) cur.mods.push_back({pi, j % p[pi]});
      data[arr[j]].push_back(cur);
    }
  }
  for (int i = 1; i <= m; ++i) {
    printf("%d\n", solve(data[i]));
  }
}
