Problem: You are given n arrays that can have different sizes. You also have a table with w columns and n rows. The i-th array is placed horizontally in the i-th row. You can slide each array within its row as long as it occupies several consecutive cells and lies completely inside the table.

You need to find the maximum sum of the integers in the j-th column for each j from 1 to w independently.

<image> Optimal placements for columns 1, 2 and 3 are shown on the pictures from left to right.

Note that you can exclude any array out of a column provided it remains in the window. In this case its value is considered to be zero.

Input

The first line contains two integers n (1 ≤ n ≤ 10^{6}) and w (1 ≤ w ≤ 10^{6}) — the number of arrays and the width of the table.

Each of the next n lines consists of an integer l_{i} (1 ≤ l_{i} ≤ w), the length of the i-th array, followed by l_{i} integers a_{i1}, a_{i2}, …, a_{il_i} (-10^{9} ≤ a_{ij} ≤ 10^{9}) — the elements of the array.

The total length of the arrays does no exceed 10^{6}.

Output

Print w integers, the i-th of them should be the maximum sum for column i.

Examples

Input


3 3
3 2 4 8
2 2 5
2 6 3


Output


10 15 16 


Input


2 2
2 7 8
1 -8


Output


7 8 

Note

Illustration for the first example is in the statement.

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
struct FT {
  int n;
  vector<long long> vals;
  FT(const int n) : n(n), vals(vector<long long>(n + 1, 0)) {}
  void update(int i, const long long x) {
    for (++i; i <= n; i += i & -i) vals[i] += x;
  }
  long long query(int i) const {
    assert(i >= -1 && i < n);
    long long sum = 0;
    for (++i; i; i -= i & -i) sum += vals[i];
    return sum;
  }
  long long query(int i, int j) const { return query(j) - query(i - 1); }
};
int sum = 0;
struct Range {
  int l, r, k;
  Range(const int l, const int r, const int k) : l(l), r(r), k(k) {
    if (k == 2) sum += r - l + 1;
  }
  ~Range() {
    if (k == 2) sum -= r - l + 1;
  }
  bool operator<(const Range &other) const {
    if (l != other.l) return l < other.l;
    return r < other.r;
  }
};
void addRange(set<Range> &ranges, const int l, const int r, const int k) {
  assert(l <= r);
  auto it = ranges.lower_bound(Range(l, l, 0));
  while (it != ranges.end() && it->r <= r) it = ranges.erase(it);
  if (it != ranges.end() && it->l <= r) {
    ranges.emplace(r + 1, it->r, it->k);
    it = ranges.erase(it);
  }
  if (it != ranges.begin() && (--it)->r >= l) {
    ranges.emplace(it->l, l - 1, it->k);
    if (it->r > r) ranges.emplace(r + 1, it->r, it->k);
    ranges.erase(it);
  }
  ranges.emplace(l, r, k);
}
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr), cout.tie(nullptr);
  int n, m;
  cin >> n >> m;
  FT ft(m + 1);
  while (n--) {
    int k;
    cin >> k;
    vector<array<int, 3>> v = {{0, 0, (m - k) - 1}, {0, m - (m - k), m - 1}};
    if (k == m) v.clear();
    for (int i = 0; i < k; ++i) {
      int x;
      cin >> x;
      v.push_back(array<int, 3>{x, i, i + m - k});
    }
    sort(v.begin(), v.end());
    set<Range> ranges;
    for (auto e : v) addRange(ranges, e[1], e[2], e[0]);
    for (auto range : ranges) {
      ft.update(range.l, range.k);
      ft.update(range.r + 1, -range.k);
    }
  }
  for (int i = 0; i < m; ++i) cout << ft.query(i) << ' ';
  return 0;
}