#include <bits/stdc++.h>
using namespace std;
template <class T, class S>
ostream& operator<<(ostream& os, const pair<T, S>& v) {
  return os << "(" << v.first << ", " << v.second << ")";
}
template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
  os << "[";
  for (int i = int(0); i <= int((static_cast<int>((v).size())) - 1); ++i) {
    if (i) os << ", ";
    os << v[i];
  }
  return os << "]";
}
template <class T>
bool setmax(T& _a, T _b) {
  if (_b > _a) {
    _a = _b;
    return true;
  }
  return false;
}
template <class T>
bool setmin(T& _a, T _b) {
  if (_b < _a) {
    _a = _b;
    return true;
  }
  return false;
}
template <class T>
T gcd(T _a, T _b) {
  return _b == 0 ? _a : gcd(_b, _a % _b);
}
struct NumSet {
  int c[44], r[44];
  NumSet() { memset(c, 0, sizeof(c)), memset(r, 0, sizeof(r)); }
  bool insert(long long x, long long p) {
    const long long copy = x;
    for (int y = 2; y <= x; ++y) {
      int z = 1;
      while (x % y == 0) {
        z *= y, x /= y;
        if (c[z] > 0 && r[z] != p % z) return false;
      }
    }
    x = copy;
    for (int y = 2; y <= x; ++y) {
      int z = 1;
      while (x % y == 0) {
        z *= y, x /= y;
        ++c[z], r[z] = p % z;
      }
    }
    return true;
  }
  void erase(long long x) {
    for (int y = 2; y <= x; ++y) {
      int z = 1;
      while (x % y == 0) {
        z *= y, x /= y;
        --c[z];
      }
    }
  }
};
int solve(const vector<pair<long long, long long>>& a) {
  if (a.empty()) return 0;
  int i = 0, ans = 0;
  NumSet s;
  for (int j = int(0); j <= int((static_cast<int>((a).size())) - 1); ++j) {
    while (!s.insert(a[j].first, a[j].second)) {
      s.erase(a[i++].first);
    }
    setmax(ans, j - i + 1);
  }
  return ans;
}
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  vector<vector<pair<int, pair<long long, long long>>>> a(m);
  for (int i = int(0); i <= int((n)-1); ++i) {
    int k;
    scanf("%d", &k);
    for (int j = int(0); j <= int((k)-1); ++j) {
      int x;
      scanf("%d", &x);
      --x;
      a[x].push_back(make_pair(i, make_pair(k, j)));
    }
  }
  for (int i = int(0); i <= int((m)-1); ++i) {
    int ans = 0, last = -1;
    vector<pair<long long, long long>> cur;
    for (const auto& kv : a[i]) {
      if (kv.first > last + 1) {
        setmax(ans, solve(cur));
        cur.clear();
      }
      last = kv.first, cur.push_back(kv.second);
    }
    setmax(ans, solve(cur));
    printf("%d\n", ans);
  }
  return 0;
}
