#include <bits/stdc++.h>
using namespace std;
int n, m;
int primes[12];
int ans[123123];
int k[123123];
int lgn[123123];
set<pair<int, int>> setki[123123];
void buduj() {
  primes[0] = 2;
  primes[1] = 3;
  primes[2] = 5;
  primes[3] = 7;
  primes[4] = 11;
  primes[5] = 13;
  primes[6] = 17;
  primes[7] = 19;
  primes[8] = 23;
  primes[9] = 29;
  primes[10] = 31;
  primes[11] = 37;
  for (int i = 1; i <= 100000; ++i) {
    lgn[i] = lgn[i - 1];
    if ((1 << (lgn[i] + 1)) < i) {
      ++lgn[i];
    }
  }
}
struct res {
  bool good;
  int res[12];
  int mod[3];
};
res newRes(long long k, long long r) {
  res t;
  t.good = 1;
  for (int i = 0; i < 3; ++i) {
    t.mod[i] = 1;
    while (k % primes[i] == 0) {
      t.mod[i] *= primes[i];
      k /= primes[i];
    }
    if (t.mod[i] == 1) {
      t.mod[i] = 0;
      t.res[i] = -1;
    } else {
      t.res[i] = r % t.mod[i];
    }
  }
  for (int i = 3; i < 12; ++i) {
    if (k % primes[i] == 0) {
      t.res[i] = r % primes[i];
    } else {
      t.res[i] = -1;
    }
  }
  return t;
}
res merguj(const res& a, const res& b) {
  res c;
  c.good = 1;
  if (!a.good || !b.good) {
    c.good = 0;
    return c;
  }
  for (int i = 0; i < 3; ++i) {
    if (a.res[i] == -1 || b.res[i] == -1) {
      c.res[i] = max(a.res[i], b.res[i]);
      c.mod[i] = max(a.mod[i], b.mod[i]);
      continue;
    }
    if (a.mod[i] > b.mod[i]) {
      if ((a.res[i] % b.mod[i]) != b.res[i]) {
        c.good = 0;
        return c;
      }
      c.res[i] = a.res[i];
      c.mod[i] = a.mod[i];
    } else {
      if ((b.res[i] % a.mod[i]) != a.res[i]) {
        c.good = 0;
        return c;
      }
      c.res[i] = b.res[i];
      c.mod[i] = b.mod[i];
    }
  }
  for (int i = 3; i < 12; ++i) {
    if (a.res[i] == -1 || b.res[i] == -1) {
      c.res[i] = max(a.res[i], b.res[i]);
      continue;
    }
    if (a.res[i] != b.res[i]) {
      c.good = 0;
      return c;
    }
    c.res[i] = a.res[i];
  }
  return c;
}
void loduj() {
  cin >> n >> m;
  int x;
  for (int i = 0; i < n; ++i) {
    cin >> k[i];
    for (int j = 0; j < k[i]; ++j) {
      cin >> x;
      setki[i].insert(make_pair(x, j));
    }
  }
}
res pom[123123][18];
res fastInt(int p, int q) {
  int l = lgn[q - p + 1];
  return merguj(pom[p][l], pom[q + 1 - (1 << l)][l]);
}
int solvuj(vector<pair<long long, long long>>& v) {
  int n = v.size();
  for (int i = 0; i < n; ++i) pom[i][0] = newRes(v[i].first, v[i].second);
  for (int i = 1; i < 18; ++i)
    for (int j = 0; (j + (1 << i)) <= n; ++j)
      pom[j][i] = merguj(pom[j][i - 1], pom[j + (1 << (i - 1))][i - 1]);
  int ans = 0;
  int j = 0;
  for (int i = 0; i < n; ++i) {
    while (j < n && fastInt(i, j).good) {
      ++j;
    }
    ans = max(ans, j - i);
  }
  return ans;
}
void solve() {
  int j, x;
  for (int i = 0; i < n; ++i)
    for (auto tmp : setki[i]) {
      x = tmp.first;
      vector<pair<long long, long long>> v;
      v.push_back(make_pair(k[i], tmp.second));
      j = i + 1;
      while (j < n) {
        auto ptr = setki[j].lower_bound(make_pair(x, -1));
        if (ptr == setki[j].end() || (ptr->first) != x) {
          break;
        }
        v.push_back(make_pair(k[j], (ptr->second)));
        setki[j].erase(ptr);
        ++j;
      }
      ans[x] = max(ans[x], solvuj(v));
    }
}
int main() {
  ios_base::sync_with_stdio(0);
  buduj();
  loduj();
  solve();
  for (int i = 1; i <= m; ++i) {
    cout << ans[i] << endl;
  }
}
