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;
void dbg() { std::cout << "  #\n"; }
template <typename T, typename... Args>
void dbg(T a, Args... args) {
  std::cout << a << ' ';
  dbg(args...);
}
const long long maxn = 1e6 + 10;
const long long MAX = 1000;
const long long inf = 1e9;
const long long mod = 1e9 + 7;
long long n, w;
vector<long long> a[maxn];
struct segment_tree {
  long long x, y, z, w;
} tr[maxn * 4];
void pushup(long long k) { tr[k].z = max(tr[k * 2].z, tr[k * 2 + 1].z); }
void pushdown(long long k) {
  long long w = tr[k].w;
  tr[k * 2].w += w;
  tr[k * 2].z += w;
  tr[k * 2 + 1].w += w;
  tr[k * 2 + 1].z += w;
  tr[k].w = 0;
}
void build(long long i, long long k, long long l, long long r) {
  tr[k].w = 0, tr[k].x = l, tr[k].y = r;
  if (l == r) {
    tr[k].z = a[i][l - 1];
    return;
  }
  long long mid = (l + r) / 2;
  build(i, k * 2, l, mid);
  build(i, k * 2 + 1, mid + 1, r);
  pushup(k);
}
void update(long long k, long long l, long long r, long long w) {
  if (tr[k].y < l || tr[k].x > r) return;
  if (l <= tr[k].x && tr[k].y <= r) {
    tr[k].w += w;
    tr[k].z += w;
    return;
  }
  if (tr[k].w) pushdown(k);
  update(k * 2, l, r, w);
  update(k * 2 + 1, l, r, w);
  pushup(k);
}
long long query(long long k, long long l, long long r) {
  if (tr[k].y < l || tr[k].x > r) return -inf;
  if (l <= tr[k].x && tr[k].y <= r) {
    return tr[k].z;
  }
  if (tr[k].w) pushdown(k);
  return max(query(k * 2, l, r), query(k * 2 + 1, l, r));
}
long long ans[maxn];
void solve() {
  cin >> n >> w;
  for (long long i = (1); i <= (n); ++i) {
    long long num;
    cin >> num;
    for (long long j = (1); j <= (num); ++j) {
      long long x;
      cin >> x;
      a[i].push_back(x);
    }
  }
  for (long long i = (1); i <= (n); ++i) {
    long long l = a[i].size();
    build(i, 1, 1, l);
    if (l * 2 < w + 1) {
      long long maxx = 0;
      for (long long j = (1); j <= (l); ++j) {
        maxx = max(maxx, a[i][j - 1]);
        ans[j] += maxx;
        ans[j + 1] -= maxx;
      }
      maxx = 0;
      long long pos = l - 1;
      for (long long j = (w); j >= (w - l + 1); --j) {
        maxx = max(maxx, a[i][pos]);
        ans[j] += maxx;
        ans[j + 1] -= maxx;
        pos--;
      }
      maxx = max(0ll, *max_element((a[i]).begin(), (a[i]).end()));
      ans[l + 1] += maxx;
      ans[w - l + 1] -= maxx;
    } else {
      long long maxx = 0;
      for (long long j = (1); j <= (w - l); ++j) {
        maxx = max(maxx, a[i][j - 1]);
        ans[j] += maxx;
        ans[j + 1] -= maxx;
      }
      maxx = 0;
      long long pos = l - 1;
      for (long long j = (w); j >= (l + 1); --j) {
        maxx = max(maxx, a[i][pos]);
        ans[j] += maxx;
        ans[j + 1] -= maxx;
        pos--;
      }
      for (long long j = (w - l + 1); j <= (l); ++j) {
        maxx = query(1, j - w + l, j);
        ans[j] += maxx;
        ans[j + 1] -= maxx;
      }
    }
  }
  for (long long i = (1); i <= (w); ++i) {
    ans[i] += ans[i - 1];
    cout << ans[i] << " \n"[i == n];
  }
}
signed main() {
  std::ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  long long T = 1;
  while (T--) {
    solve();
  }
}