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;
vector<vector<int> > v(1000005);
long long int sum[1000005], dp[1000005];
int aage[1000005], piche[1000005];
int sp[1000005][20], po[20], ar[2 * 1000005];
void small(int i, int w) {
  int j, s = v[i].size();
  aage[0] = v[i][0];
  for (j = 1; j < s; j++) aage[j] = max(aage[j - 1], v[i][j]);
  piche[s - 1] = v[i][s - 1];
  for (j = s - 2; j >= 0; j--) piche[j] = max(piche[j + 1], v[i][j]);
  for (j = 0; j < s - 1; j++) sum[j] += max(0, aage[j]);
  for (j = w - s; j < w; j++) sum[j] += max(0, piche[j - w + s]);
  aage[s - 1] = max(0, aage[s - 1]);
  dp[s - 1] += aage[s - 1];
  dp[w - s] -= aage[s - 1];
  return;
}
void pre() {
  int i, k;
  ar[1] = 0, k = 1, po[0] = 1;
  while (k < 1000005) {
    for (i = k + 1; i < 2 * k; i++) ar[i] = ar[k];
    ar[2 * k] = 1 + ar[k], k *= 2;
  }
  for (i = 1; i < 20; i++) po[i] = 2 * po[i - 1];
  return;
}
void update(int i) {
  int j, k, n = v[i].size();
  for (j = n - 1; j >= 0; j--) {
    sp[j][0] = v[i][j];
    for (k = 1; k < 20; k++)
      if (j + po[k] <= n)
        sp[j][k] = max(sp[j][k - 1], sp[j + po[k - 1]][k - 1]);
  }
  return;
}
int query(int a, int b) {
  int y, x = b - a + 1;
  y = ar[x], x -= po[y];
  return max(sp[a][y], sp[a + x][y]);
}
void big(int i, int w) {
  int j, s = v[i].size();
  update(i);
  for (j = 0; j < w - s; j++) sum[j] += max(0, query(0, j));
  for (j = s; j < w; j++) sum[j] += max(0, query(j - w + s, s - 1));
  for (j = w - s; j < s; j++) sum[j] += query(j - w + s, j);
  return;
}
int main() {
  int n, w, i, j, s;
  scanf("%d%d", &n, &w);
  for (i = 0; i < n; i++) {
    scanf("%d", &s);
    v[i].resize(s);
    for (j = 0; j < s; j++) scanf("%d", &v[i][j]);
  }
  pre();
  for (i = 0; i < n; i++) {
    s = v[i].size();
    if (w >= 2 * s)
      small(i, w);
    else
      big(i, w);
  }
  for (i = 0; i < w; i++) {
    cout << sum[i] + dp[i] << " ";
    dp[i + 1] += dp[i];
  }
}