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;
using namespace std;
const int N = 1e6 + 100;
const int inf = 1e9 + 100;
int n, w, m, a[N], seg[N << 2];
long long fen[N];
void change(int dex, int val, int v = 1, int s = 0, int e = N) {
  if (dex < s || e <= dex) {
    return;
  }
  if (e - s == 1) {
    seg[v] = val;
    return;
  }
  int mid = (s + e) >> 1, lc = v << 1, rc = lc | 1;
  change(dex, val, lc, s, mid);
  change(dex, val, rc, mid, e);
  seg[v] = max(seg[lc], seg[rc]);
}
int get_max(int l, int r, int v = 1, int s = 0, int e = N) {
  if (r <= s || e <= l) return -inf;
  if (l <= s && e <= r) return seg[v];
  int mid = (s + e) >> 1, lc = v << 1, rc = lc | 1;
  return max(get_max(l, r, lc, s, mid), get_max(l, r, rc, mid, e));
}
void add(int dex, long long val) {
  for (++dex; dex < N; dex += dex & -dex) fen[dex] += val;
}
long long get(int dex) {
  long long res = 0;
  for (; dex; dex ^= dex & -dex) res += fen[dex];
  return res;
}
void ADD(int l, int r, long long x) {
  add(l, x);
  add(r, -x);
}
void act(int i) {
  ADD(i, i + 1, max(i + m < w || i >= w ? 0 : -inf, get_max(i + m - w, i + 1)));
}
void get_line() {
  int maxi = 0;
  cin >> m;
  for (int i = 0; i < m; i++) {
    cin >> a[i];
    change(i, a[i]);
    maxi = max(maxi, a[i]);
  }
  for (int i = 0; i < m; i++) {
    act(i);
  }
  for (int i = 0; i < m && w - i - 1 >= m; i++) {
    act(w - i - 1);
  }
  if (2 * m < w) {
    ADD(m, w - m, maxi);
  }
  for (int i = 0; i < m; i++) {
    change(i, 0);
  }
}
int main() {
  cin >> n >> w;
  for (int i = 0; i < n; i++) {
    get_line();
  }
  for (int i = 0; i < w; i++) {
    cout << get(i + 1) << ' ';
  }
}