#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int x = 0, ch;
  while (!isdigit(ch = getchar()))
    ;
  while (isdigit(ch)) x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar();
  return x;
}
template <typename T>
inline T gcd(T a, T b) {
  return !b ? a : gcd(b, a % b);
}
struct Node {
  int len, pos, id;
};
struct prime {
  int p, c;
};
const int MAXN = 100000;
vector<Node> a[MAXN + 1];
vector<prime> d[41];
int pri[45][10];
long long pw[45][10];
int main() {
  int n = read(), m = read();
  for (int i = 1; i <= n; i++) {
    int len = read();
    for (int j = 0; j < len; j++) {
      int x = read();
      a[x].push_back((Node){len, j, i});
    }
  }
  for (int i = 2; i <= 40; i++) {
    int tmp = i;
    for (int j = 2; j <= i; j++) {
      if (tmp % j) continue;
      int c = 0;
      while (tmp % j == 0) tmp /= j, ++c;
      d[i].push_back((prime){j, c});
    }
    long long mul = 1;
    for (int j = 0; j < 10; j++) pw[i][j] = mul, mul *= i;
  }
  for (int i = 1; i <= m; i++) {
    int si = a[i].size(), res = 1, l = 0;
    if (!si) {
      puts("0");
      continue;
    }
    long long lcm = a[i][0].len, pos = a[i][0].pos, las = a[i][0].id;
    int s = d[lcm].size();
    for (int j = 0; j < s; j++) {
      prime z = d[lcm][j];
      pri[z.p][z.c]++;
    }
    for (int r = 1; r < si; r++) {
      Node x = a[i][r], y = a[i][l];
      if (x.id != las + 1) {
        l = r, lcm = x.len, pos = x.pos;
        memset(pri, 0, sizeof(pri));
      } else {
        long long g = gcd(lcm, (long long)x.len);
        while (l < r && abs(pos - x.pos) % g) {
          s = d[y.len].size();
          for (int j = 0; j < s; j++) {
            prime z = d[y.len][j];
            pri[z.p][z.c]--;
            if (!pri[z.p][z.c]) {
              int flag = 0;
              for (int k = z.c + 1; k < 10; k++) flag |= pri[z.p][k];
              if (!flag) {
                lcm /= pw[z.p][z.c];
                for (int k = z.c; k >= 1; k--)
                  if (pri[z.p][k]) {
                    lcm *= pw[z.p][k];
                    break;
                  }
              }
            }
          }
          g = gcd(lcm, (long long)x.len);
          y = a[i][++l];
          pos %= lcm;
        }
        long long tpos = x.pos;
        while (pos != tpos) {
          if (pos < tpos)
            pos += (tpos - pos + lcm - 1) / lcm * lcm;
          else
            tpos += (pos - tpos + x.len - 1) / x.len * x.len;
        }
        lcm = lcm / g * x.len;
      }
      las = x.id;
      s = d[x.len].size();
      for (int j = 0; j < s; j++) {
        prime z = d[x.len][j];
        pri[z.p][z.c]++;
      }
      res = max(res, r - l + 1);
    }
    printf("%d\n", res);
    memset(pri, 0, sizeof(pri));
  }
  return 0;
}
