#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10, maxk = 42, mod = 1e9 + 7;
const long long inf = 1e18;
vector<pair<int, pair<int, int> > > v[maxn];
vector<int> dv[maxk];
pair<int, int> MD[maxk];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  for (int i = 2; i < maxk; i++) {
    for (int j = i; j < maxk; j += i) dv[j].push_back(i);
  }
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    int md;
    cin >> md;
    for (int j = 0; j < md; j++) {
      int x;
      cin >> x;
      v[--x].push_back({i, {md, j}});
    }
  }
  for (int i = 0; i < m; i++) {
    int ans = 0, l = -1;
    memset(MD, -1, sizeof MD);
    for (int r = 0; r < int((v[i]).size()); r++) {
      int ps = v[i][r].first, md = v[i][r].second.first,
          rm = v[i][r].second.second;
      if (r != 0 && v[i][r - 1].first + 1 != ps) l = r - 1;
      for (int x : dv[md]) {
        if (MD[x].first != -1 && MD[x].second != rm % x) {
          while (l < MD[x].first) ++l;
        }
        MD[x] = {r, rm % x};
      }
      ans = max(ans, r - l);
    }
    cout << ans << "\n";
  }
}
