#include <bits/stdc++.h>
using namespace std;
const int N = 100005;
const int pri[] = {0, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37};
int n, m, L[N], a[N];
vector<pair<int, int> > vec[N];
struct node {
  int fl;
  int a[15];
  int b[15];
  node() {
    fl = 1;
    for (int i = (int)(1); i <= (int)(12); i++) a[i] = 1;
    for (int i = (int)(1); i <= (int)(12); i++) b[i] = 0;
  }
  void insert(int x, int y) {
    for (int i = (int)(1); i <= (int)(12); i++) {
      for (; x % pri[i] == 0;) x /= pri[i], a[i] *= pri[i];
      b[i] = y % a[i];
    }
  }
  node operator+(const node &tmp) const {
    node ans;
    ans.fl = fl & tmp.fl;
    for (int i = (int)(1); i <= (int)(12); i++)
      if (a[i] >= tmp.a[i]) {
        if (b[i] % tmp.a[i] != tmp.b[i]) ans.fl = 0;
        ans.a[i] = a[i];
        ans.b[i] = b[i];
      } else {
        if (tmp.b[i] % a[i] != b[i]) ans.fl = 0;
        ans.a[i] = tmp.a[i];
        ans.b[i] = tmp.b[i];
      }
    return ans;
  }
} b[N], c[N];
void solve(int l, int r, int &ans) {
  for (int i = (int)(l); i <= (int)(r); i++) {
    b[i] = node();
    b[i].insert(L[i], a[i]);
  }
  int pos = l, t = l - 1;
  node suf = node();
  for (int i = (int)(l); i <= (int)(r); i++) {
    suf = suf + b[i];
    for (; pos <= i;) {
      for (; pos <= t && (suf + c[pos]).fl == 0; ++pos)
        ;
      if (pos > i) break;
      if (pos <= t) {
        ans = max(ans, i - pos + 1);
        break;
      } else {
        c[i + 1] = node();
        for (int j = (int)(i); j >= (int)(pos); j--) c[j] = c[j + 1] + b[j];
        t = i;
        suf = node();
      }
    }
  }
}
void solve(vector<pair<int, int> > &vec) {
  if (!vec.size()) return puts("0"), void(0);
  int ans = 0, l = 0;
  for (auto i : vec) a[i.first] = i.second;
  for (int i = (int)(1); i <= (int)(vec.size() - 1); i++)
    if (vec[i].first != vec[i - 1].first + 1)
      solve(vec[l].first, vec[i - 1].first, ans), l = i;
  solve(vec[l].first, vec.back().first, ans);
  printf("%d\n", ans);
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = (int)(1); i <= (int)(n); i++) {
    scanf("%d", &L[i]);
    for (int j = (int)(1); j <= (int)(L[i]); j++) {
      int x;
      scanf("%d", &x);
      vec[x].push_back(pair<int, int>(i, j));
    }
  }
  for (int i = (int)(1); i <= (int)(m); i++) solve(vec[i]);
}
