#include <bits/stdc++.h>
namespace io {
int F() {
  int n = 0, F = 1;
  char ch;
  while ((ch = getchar()) != '-' && (ch < '0' || ch > '9'))
    ;
  ch == '-' ? F = 0 : n = ch - '0';
  while ((ch = getchar()) >= '0' && ch <= '9')
    n = (n << 1) + (n << 3) + ch - '0';
  return F ? n : -n;
}
long long G() {
  long long n = 0, F = 1;
  char ch;
  while ((ch = getchar()) != '-' && (ch < '0' || ch > '9'))
    ;
  ch == '-' ? F = 0 : n = ch - '0';
  while ((ch = getchar()) >= '0' && ch <= '9')
    n = (n << 1) + (n << 3) + ch - '0';
  return F ? n : -n;
}
}  // namespace io
const int d[41] = {0, 0,  2,  3,  4,  5,  2, 7, 8, 9,  2, 11, 4, 13,
                   2, 3,  16, 17, 2,  19, 4, 3, 2, 23, 8, 25, 2, 27,
                   4, 29, 2,  31, 32, 3,  2, 5, 4, 37, 2, 3,  8};
struct vec {
  int no;
  int pl;
  vec* next;
} v[333333], *pv = v + 111111;
void insert(int a, int no, int pl) {
  *pv = (vec){no, pl, v[a].next};
  v[a].next = pv++;
}
int len[111111];
int id[44];
int num[20] = {0,  2, 4,  8,  16, 32, 3,  9,  27, 5,
               25, 7, 11, 13, 17, 19, 23, 29, 31, 37};
int mem[340], *pm = mem;
int *cnt[20], cc[20];
int S[20];
struct hi {
  int* a;
  int v;
} h[1111111];
int ph;
int lg[65577];
bool chk() {
  int n;
  n = -1;
  for (register int i = 5; i >= 1; --i)
    if (cc[i]) {
      int tmp = ((unsigned)(S[i]) >= 65536 ? 16 + lg[(unsigned)(S[i]) >> 16]
                                           : lg[S[i]]);
      if (n == -1)
        n = tmp;
      else if (n % num[i] != tmp)
        return 0;
    }
  n = -1;
  for (register int i = 8; i >= 6; --i)
    if (cc[i]) {
      int tmp = ((unsigned)(S[i]) >= 65536 ? 16 + lg[(unsigned)(S[i]) >> 16]
                                           : lg[S[i]]);
      if (n == -1)
        n = tmp;
      else if (n % num[i] != tmp)
        return 0;
    }
  n = -1;
  for (register int i = 10; i >= 9; --i)
    if (cc[i]) {
      int tmp = ((unsigned)(S[i]) >= 65536 ? 16 + lg[(unsigned)(S[i]) >> 16]
                                           : lg[S[i]]);
      if (n == -1)
        n = tmp;
      else if (n % num[i] != tmp)
        return 0;
    }
  return 1;
}
int pl[111111];
int main() {
  for (register int i = 2, j = 1; i < 65536; i <<= 1, ++j) lg[i] = j;
  int n = io::F(), m = io::F();
  for (register int i = 1; i <= n; ++i) {
    len[i] = io::F();
    for (register int j = 0; j < len[i]; ++j) insert(io::F(), i, j);
  }
  for (register int i = 1; i < 20; ++i)
    cnt[i] = pm, pm += num[i], id[num[i]] = i;
  for (register int i = 1; i <= m; ++i) {
    int ans = 0, l, r;
    for (register vec *la = v + i, *t = v[i].next; t;
         t = t->next, la = la->next) {
      l = t->no;
      pl[t->no] = t->pl;
      if (t->no + 1 != la->no) {
        r = t->no;
        while (ph) *h[ph].a = h[ph].v, --ph;
      }
      int T = len[t->no];
      int bug = 0;
      while (T != 1) {
        int D = id[d[T]];
        h[++ph] = (hi){&(cnt[D][t->pl % d[T]]), (cnt[D][t->pl % d[T]])};
        ;
        h[++ph] = (hi){&(cc[D]), (cc[D])};
        ;
        if (cnt[D][t->pl % d[T]]++ == 0) {
          h[++ph] = (hi){&(S[D]), (S[D])};
          ;
          if (D <= 10) S[D] |= 1u << t->pl % d[T];
          if (cc[D]++ == 1) ++bug;
        }
        T /= d[T];
      }
      while (bug) {
        int T = len[r];
        while (T != 1) {
          int D = id[d[T]];
          if (--cnt[D][pl[r] % d[T]] == 0) {
            if (D <= 10) S[D] ^= 1u << pl[r] % d[T];
            if (--cc[D] == 1) --bug;
          }
          T /= d[T];
        }
        r--;
      }
      while (!chk()) {
        int T = len[r];
        while (T != 1) {
          int D = id[d[T]];
          if (--cnt[D][pl[r] % d[T]] == 0) {
            if (D <= 10) S[D] ^= 1u << pl[r] % d[T];
            if (--cc[D] == 1) --bug;
          }
          T /= d[T];
        }
        r--;
      }
      (ans < (r - l + 1) ? ans = (r - l + 1), 1 : 0);
    }
    printf("%d\n", ans);
  }
  return 0;
}
