#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:64000000")
using namespace std;
void __never(int a) { printf("\nOPS %d", a); }
void __die(int a) { printf("%d", (a * a) / (a + a)); }
int n, m;
struct Item {
  int len;
  int id;
  int pos;
};
vector<Item> ms[200500];
vector<int> ds[50];
void init() {
  freopen("a.in", "r", stdin);
  freopen("a.out", "w", stdout);
}
int sol(const vector<Item>& v) {
  int ans = 0;
  vector<int> rem(50, -1);
  vector<int> id(50, -1);
  int be = 0;
  for (int(en) = (0); (en) <= ((int)((v).size()) - 1); ++(en)) {
    auto& it = v[en];
    int conf = -1;
    for (int d : ds[it.len]) {
      int r = it.pos % d;
      if (rem[d] != -1 && rem[d] != r) {
        conf = max(conf, id[d]);
      }
      rem[d] = r;
      id[d] = en;
    }
    if (en > 0 && v[en].id > v[en - 1].id + 1) {
      conf = en - 1;
    }
    while (be <= conf) {
      for (int d : ds[v[be].len]) {
        if (id[d] == be) {
          id[d] = -1;
          rem[d] = -1;
        }
      }
      be++;
    }
    ans = max(ans, en - be + 1);
  }
  return ans;
}
void sol() {
  cin >> n >> m;
  int h, h2;
  for (int(i) = (1); (i) <= (n); ++(i)) {
    cin >> h;
    for (int(j) = (0); (j) <= (h - 1); ++(j)) {
      cin >> h2;
      ms[h2].push_back(Item{h, i, j});
    }
  }
  for (int(i) = (1); (i) <= (m); ++(i)) {
    cout << sol(ms[i]) << "\n";
  }
}
int main() {
  for (int(i) = (1); (i) <= (50 - 1); ++(i)) {
    for (int(j) = (2); (j) <= (i); ++(j)) {
      if (i % j == 0) ds[i].push_back(j);
    }
  }
  sol();
  return 0;
}
