#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC optimize("no-stack-protector,fast-math")
using namespace std;
const long long N = 2e5 + 100, OO = 1e9 + 7, K = 3e5 + 100, T = 22, M = 1e9 + 7,
                P = 6151, SQ = 1300, lg = 22;
long long use[42][42];
vector<pair<long long, pair<long long, long long> > > g[N];
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
bool pd(long long a, long long b) {
  for (long long i = 1; i <= 40; i++)
    for (long long j = 0; j < i; j++)
      if (use[i][j])
        if ((b - j) % gcd(a, i) != 0) return 0;
  return 1;
}
int32_t main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  long long n, m;
  cin >> n >> m;
  for (long long i = 0; i < n; i++) {
    long long k;
    cin >> k;
    for (long long j = 0; j < k; j++) {
      long long w;
      cin >> w;
      g[w].push_back({i, {j, k}});
    }
  }
  for (long long i = 1; i <= m; i++) {
    long long ans = 0;
    long long p = (long long)g[i].size();
    for (long long j = 0; j < p; j++) {
      if (j != 0 && g[i][j].first == g[i][j - 1].first + 1) continue;
      long long q = j;
      for (q = j + 1; q < p && g[i][q].first == g[i][q - 1].first + 1; q++)
        ;
      memset(use, 0, sizeof(use));
      long long no = j - 1;
      for (long long f = j; f < q; f++) {
        while (no < f) {
          use[g[i][no + 1].second.second][g[i][no + 1].second.first]++;
          no++;
        }
        while (no + 1 < q) {
          if (pd(g[i][no + 1].second.second, g[i][no + 1].second.first)) {
            use[g[i][no + 1].second.second][g[i][no + 1].second.first]++;
            no++;
          } else
            break;
        }
        ans = max(ans, no - f + 1);
        use[g[i][f].second.second][g[i][f].second.first]--;
      }
    }
    cout << ans << endl;
  }
  return 0;
}
