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;
const int maxn = 1 * 1000 * 1000 + 10, inf = 1 * 1000 * 1000 * 1000 + 10;
int n, w, l[maxn], mx[maxn], x[maxn], ind[maxn], dp[maxn], cnt, ci, L, R, ql,
    qr, dpl[maxn];
long long ans[maxn], cur, a[maxn], tmx;
vector<pair<int, int>> tmp;
int main() {
  memset(dp, -1, sizeof dp);
  memset(dpl, -1, sizeof dpl);
  ios::sync_with_stdio(0);
  scanf("%d %d", &n, &w);
  for (int i = 0; i < n; i++) {
    scanf("%d", &l[i]);
    ind[i + 1] = ind[i] + l[i];
    for (int j = 0; j < l[i]; j++) {
      scanf("%d", &x[cnt]);
      while ((((int)tmp.size())) > 0 && tmp.back().first <= x[cnt]) {
        dp[tmp.back().second] = cnt;
        tmp.pop_back();
      }
      tmp.push_back({x[cnt], cnt});
      mx[i] = max(mx[i], x[cnt]);
      cnt++;
    }
    tmp.clear();
    ql = qr = -1;
    ci = ind[i];
    for (int j = 0; j < w; j++) {
      tmx = -inf;
      L = j - w + l[i];
      R = j;
      if (L <= 0 && R >= l[i] - 1 && R - L >= l[i]) {
        ql = j;
        break;
      }
      while (ci < cnt && dp[ci] <= R + ind[i] && dp[ci] != -1) ci = dp[ci];
      if (L + ind[i] - 1 == ci) {
        ci++;
        while (ci < cnt && dp[ci] <= R + ind[i] && dp[ci] != -1) ci = dp[ci];
      }
      if (ci < cnt) tmx = x[ci];
      if (L < 0 || R >= l[i]) tmx = max(tmx, (long long)0);
      ans[j] += tmx;
    }
    if (ql != -1) {
      ci = cnt - 1;
      for (int j = cnt - 1;; j--) {
        if (j >= ind[i]) {
          while ((((int)tmp.size())) > 0 && tmp.back().first <= x[j]) {
            dpl[tmp.back().second] = j;
            tmp.pop_back();
          }
          tmp.push_back({x[j], j});
        }
        tmx = -inf;
        L = j;
        R = j + w - l[i];
        if (L - ind[i] <= 0 && R - ind[i] >= l[i] - 1 && R - L >= l[i]) {
          qr = j + w - cnt + 1;
          break;
        }
        while (ci >= ind[i] && dpl[ci] >= L && dpl[ci] != -1) ci = dpl[ci];
        if (ci == R + 1) {
          ci--;
          while (ci >= ind[i] && dpl[ci] >= L && dpl[ci] != -1) ci = dpl[ci];
        }
        if (ci >= ind[i]) tmx = x[ci];
        if (L - ind[i] < 0 || R - ind[i] >= l[i]) tmx = max(tmx, (long long)0);
        ans[j + w - cnt] += tmx;
      }
    }
    if (ql != -1) {
      a[ql] += mx[i];
      a[qr] -= mx[i];
    }
  }
  for (int i = 0; i < w; i++) {
    cur += a[i];
    printf("%lld ", cur + ans[i]);
  }
  return 0;
}