#include <bits/stdc++.h>
using namespace std;
long long max(long long a, long long b) {
  if (a > b) {
    return a;
  } else {
    return b;
  }
}
long long min(long long a, long long b) {
  if (a < b) {
    return a;
  } else {
    return b;
  }
}
int n, m;
int res[600001];
vector<pair<pair<int, int>, pair<int, int> > > Q;
vector<pair<int, int> > Y;
vector<int> p[60];
int cyc[60], cnt[60];
void regist(pair<int, int> x) {
  for (int i = (0); i < (p[x.second].size()); i++) {
    int fact = p[x.second][i];
    cyc[fact] = (x.first % fact);
    cnt[fact]++;
  }
}
void unregist(pair<int, int> x) {
  for (int i = (0); i < (p[x.second].size()); i++) {
    int fact = p[x.second][i];
    cyc[fact] = (x.first % fact);
    cnt[fact]--;
  }
}
bool ok(pair<int, int> x) {
  for (int i = (0); i < (p[x.second].size()); i++) {
    int fact = p[x.second][i];
    int cor = x.first % fact;
    if (cnt[fact] == 0 || cyc[fact] == cor) {
    } else
      return false;
  }
  return true;
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = (1); i <= (40); i++) {
    for (int j = i; j <= 40; j += i) p[j].push_back(i);
  }
  for (int i = (1); i <= (n); i++) {
    int k;
    scanf("%d", &k);
    for (int j = (1); j <= (k); j++) {
      int t;
      scanf("%d", &t);
      Q.push_back(make_pair(make_pair(t, i), make_pair(j, k)));
    }
  }
  sort(Q.begin(), Q.end());
  for (int i = (0); i < (Q.size()); i++) {
    pair<pair<int, int>, pair<int, int> > T = Q[i];
    Y.push_back(Q[i].second);
    if (i == Q.size() - 1 || Q[i].first.first != Q[i + 1].first.first ||
        Q[i].first.second != Q[i + 1].first.second - 1) {
      int id = T.first.first;
      int ret = 0;
      for (int x = (1); x <= (40); x++) cnt[x] = 0;
      int lr = 0, rr = 0;
      while (lr < Y.size() && rr < Y.size()) {
        while (rr < Y.size() && ok(Y[rr])) {
          regist(Y[rr]);
          rr++;
          ret = max(ret, rr - lr);
        }
        while (rr < Y.size() && lr < Y.size() && !ok(Y[rr])) {
          unregist(Y[lr]);
          lr++;
        }
      }
      res[id] = max(res[id], ret);
      while (Y.size()) Y.pop_back();
    }
  }
  for (int i = (1); i <= (m); i++) printf("%d\n", res[i]);
  return 0;
}
