#include <bits/stdc++.h>
using namespace std;
template <class X, class Y>
void minimize(X &x, const Y &y) {
  if (x > y) x = y;
}
template <class X, class Y>
void maximize(X &x, const Y &y) {
  if (x < y) x = y;
}
template <class T>
T Abs(const T &x) {
  return (x < 0 ? -x : x);
}
const int prime[] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37};
const int numPrime = 12;
struct PrimeFact {
  int base, exp, value;
  PrimeFact() { base = exp = value = 0; }
  PrimeFact(int base) {
    this->base = base;
    exp = 0;
    value = 1;
  }
};
int numSeq, maxVal, a[100100][44], len[100100];
vector<PrimeFact> primeFacts[44];
map<int, int> pos[100100];
map<pair<int, int>, int> haveMod[44];
void init(void) {
  scanf("%d%d", &numSeq, &maxVal);
  for (int i = 0, _n = (numSeq); i < _n; i = i + 1) {
    scanf("%d", &len[i]);
    for (int j = 0, _n = (len[i]); j < _n; j = j + 1) scanf("%d", &a[i][j]);
  }
}
vector<PrimeFact> getPrimeFacts(int x) {
  vector<PrimeFact> facts;
  for (int i = 2; i * i <= x; i++)
    if (x % i == 0) {
      facts.push_back(PrimeFact(i));
      while (x % i == 0) {
        facts.back().exp++;
        facts.back().value *= i;
        x /= i;
      }
    }
  if (x > 1) {
    facts.push_back(PrimeFact(x));
    facts.back().exp = 1;
    facts.back().value = x;
  }
  return facts;
}
void prepare(void) {
  for (int i = (2), _b = (44 - 1); i <= _b; i = i + 1)
    primeFacts[i] = getPrimeFacts(i);
  for (int i = 0, _n = (numSeq); i < _n; i = i + 1)
    for (int j = 0, _n = (len[i]); j < _n; j = j + 1) pos[a[i][j]][i] = j;
}
bool okPrime(int prime) {
  pair<int, int> ___prev(-1, -1);
  map<pair<int, int>, int> &curMap = haveMod[prime];
  if (curMap.empty()) return true;
  for (__typeof((curMap).begin()) it = (curMap).begin(); it != (curMap).end();
       it++) {
    pair<int, int> cur = it->first;
    if (___prev.first > 0) {
      if (cur.first == ___prev.first) return false;
      if (cur.second % ___prev.first != ___prev.second) return false;
    }
    ___prev = cur;
  }
  return true;
}
bool ok(void) {
  for (int i = 0, _n = (numPrime); i < _n; i = i + 1)
    if (!okPrime(prime[i])) return false;
  return true;
}
void insert(map<pair<int, int>, int> &mp, const pair<int, int> &key) {
  mp[key]++;
}
void remove(map<pair<int, int>, int> &mp, const pair<int, int> &key) {
  if (--mp[key] == 0) mp.erase(key);
}
int findMaxLen(int value, int ___left, int ___right) {
  int res = 1;
  int j = ___left;
  for (__typeof((primeFacts[len[___left]]).begin()) it =
           (primeFacts[len[___left]]).begin();
       it != (primeFacts[len[___left]]).end(); it++)
    insert(haveMod[it->base],
           make_pair(it->value, pos[value][___left] % it->value));
  for (int i = (___left), _b = (___right); i <= _b; i = i + 1) {
    while (j <= ___right && ok()) {
      if (++j <= ___right)
        for (__typeof((primeFacts[len[j]]).begin()) it =
                 (primeFacts[len[j]]).begin();
             it != (primeFacts[len[j]]).end(); it++)
          insert(haveMod[it->base],
                 make_pair(it->value, pos[value][j] % it->value));
    }
    maximize(res, j - i);
    for (__typeof((primeFacts[len[i]]).begin()) it =
             (primeFacts[len[i]]).begin();
         it != (primeFacts[len[i]]).end(); it++)
      remove(haveMod[it->base],
             make_pair(it->value, pos[value][i] % it->value));
  }
  return res;
}
int findMaxLen(int value) {
  vector<pair<int, int> > segments;
  vector<pair<int, int> > cur((pos[value]).begin(), (pos[value]).end());
  for (__typeof((cur).begin()) it = (cur).begin(); it != (cur).end(); it++) {
    if (segments.empty() || segments.back().second != it->first - 1)
      segments.push_back(make_pair(it->first, it->first));
    else
      segments.back().second++;
  }
  int res = 0;
  for (__typeof((segments).begin()) it = (segments).begin();
       it != (segments).end(); it++)
    maximize(res, findMaxLen(value, it->first, it->second));
  return res;
}
void process(void) {
  for (int i = (1), _b = (maxVal); i <= _b; i = i + 1)
    printf("%d\n", findMaxLen(i));
}
int main(void) {
  init();
  prepare();
  process();
  return 0;
}
