#include <bits/stdc++.h>
using namespace std;
const int maxn = 100000 + 123;
int n, m;
struct data {
  int x, k, id;
};
vector<data> con[maxn];
int gcd(int x, int y) {
  while (x && y)
    if (x >= y)
      x %= y;
    else
      y %= x;
  return x + y;
}
int preG[50][50];
void ReadData() {
  cin >> n >> m;
  for (int i = 1, _b = n; i <= _b; ++i) {
    int k;
    cin >> k;
    for (int j = 0, _b = k - 1; j <= _b; ++j) {
      int u;
      cin >> u;
      con[u].push_back((data){j, k, i});
    }
  }
}
int cntLen[50];
int rem[50];
bool possible() {
  for (int i = 1, _b = 40; i <= _b; ++i)
    if (cntLen[i])
      for (int j = i + 1, _b = 40; j <= _b; ++j)
        if (cntLen[j]) {
          if (rem[i] % preG[i][j] != rem[j] % preG[i][j]) return false;
        }
  return true;
}
int smallSolve(vector<data> &a) {
  int j = 0;
  int res = 0;
  memset(cntLen, 0, sizeof(cntLen));
  memset(rem, 0, sizeof(rem));
  for (int i = 0, _n = ((int)a.size()); i < _n; ++i) {
    while (j < i && cntLen[a[i].k] && rem[a[i].k] != a[i].x) {
      cntLen[a[j].k]--;
      j++;
    }
    cntLen[a[i].k]++;
    rem[a[i].k] = a[i].x;
    while (j < i && !possible()) {
      cntLen[a[j].k]--;
      j++;
    }
    res = max(res, i - j + 1);
  }
  return res;
}
int Solve(vector<data> &a) {
  if (!((int)a.size())) return 0;
  int j = 0;
  vector<data> b;
  int res = 0;
  for (int i = 0, _n = ((int)a.size()); i < _n; ++i) {
    while (j < i && a[i].id - a[j].id != i - j) j++;
    if (i == ((int)a.size()) - 1 || a[i].id + 1 != a[i + 1].id) {
      b.clear();
      for (int f = j, _b = i; f <= _b; ++f) b.push_back(a[f]);
      res = max(res, smallSolve(b));
    }
  }
  return res;
}
int res[maxn];
void Process() {
  for (int i = 1, _b = 40; i <= _b; ++i)
    for (int j = 1, _b = 40; j <= _b; ++j) preG[i][j] = gcd(i, j);
  for (int i = 1, _b = m; i <= _b; ++i) res[i] = Solve(con[i]);
  for (int i = 1, _b = m; i <= _b; ++i) cout << res[i] << "\n";
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ReadData();
  Process();
  return 0;
}
