#include <bits/stdc++.h>
#pragma warning(disable : 4996)
using namespace std;
int n, m;
vector<int> a[200000];
vector<pair<int, pair<int, int> > > b[200000];
pair<int, int> stat[50];
int dodo(int tar, int st, int en) {
  int i, j, k;
  int ma = 1;
  for (i = 1; i <= 40; i++) stat[i] = make_pair(0, 0);
  int last = st;
  for (i = st; i <= en; i++) {
    pair<int, int> u = b[tar][i].second;
    while (1) {
      int flag = 0;
      for (j = 1; j <= 40; j++) {
        if (u.second % j == 0) {
          if (stat[j].second && stat[j].first != u.first % j) {
            flag = 1;
            break;
          }
        }
      }
      if (flag) {
        pair<int, int> v = b[tar][last].second;
        for (j = 1; j <= 40; j++) {
          if (v.second % j == 0) stat[j].second--;
        }
        last++;
      } else {
        for (j = 1; j <= 40; j++) {
          if (u.second % j == 0) stat[j].second++, stat[j].first = u.first % j;
        }
        break;
      }
    }
    ma = max(ma, i - last + 1);
  }
  return ma;
}
int main() {
  register int i, j, k, l;
  cin >> n >> m;
  for (i = 0; i < n; i++) {
    register int x;
    scanf("%d", &x);
    for (j = 0; j < x; j++) {
      int y;
      scanf("%d", &y), y--;
      a[i].push_back(y);
      b[y].push_back(make_pair(i, make_pair(j, x)));
    }
  }
  for (i = 0; i < m; i++) {
    int last = 0;
    int ma = 0;
    for (j = 0; j < b[i].size(); j++) {
      if (j == b[i].size() - 1 || b[i][j].first + 1 != b[i][j + 1].first) {
        ma = max(ma, dodo(i, last, j));
        last = j + 1;
      }
    }
    printf("%d\n", ma);
  }
  return 0;
}
