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 long long int N = 1e6 + 5;
const long long int M = 3e5 + 5;
const long long int mod = 1e9 + 7;
const long long int m1 = 1e9 + 7;
const long long int m2 = 1e9 + 9;
const long long int p1 = 402653189;
const long long int p2 = 1610612741;
const int LN = 20;
long long int powermodm(long long int x, long long int n, long long int M) {
  long long int result = 1;
  while (n > 0) {
    if (n % 2 == 1) result = (result * x) % M;
    x = (x * x) % M;
    n = n / 2;
  }
  return result;
}
long long int power(long long int _a, long long int _b) {
  long long int _r = 1;
  while (_b) {
    if (_b % 2 == 1) _r = (_r * _a);
    _b /= 2;
    _a = (_a * _a);
  }
  return _r;
}
long long int gcd(long long int a, long long int b) {
  if (a == 0) return b;
  return gcd(b % a, a);
}
long long int lcm(long long int a, long long int b) {
  return (max(a, b) / gcd(a, b)) * min(a, b);
}
long long int dx[4] = {-1, 1, 0, 0};
long long int dy[4] = {0, 0, 1, -1};
long long int pw[LN], fact[N], invfact[N];
void pre() {
  fact[0] = 1;
  for (int i = 0; i < LN; i++) pw[i] = power(2, i);
  for (int i = 1; i < N; i++) fact[i] = (i * fact[i - 1]) % mod;
  for (int i = 0; i < N; i++) invfact[i] = powermodm(fact[i], mod - 2, mod);
}
long long int ans[N], offset;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long int i, j;
  long long int n, w;
  cin >> n >> w;
  for (j = 1; j <= n; j++) {
    long long int sz;
    cin >> sz;
    long long int a[sz + 1], ma = -LLONG_MAX;
    for (i = 1; i <= sz; i++) {
      cin >> a[i];
      ma = max(ma, a[i]);
    }
    if ((2 * sz) <= w) {
      multiset<long long int, greater<long long int> > ms;
      if (ma >= 0) offset += ma;
      for (i = 1; i <= sz; i++) {
        ms.insert(a[i]);
        if (ma >= 0) ans[i] -= ma;
        long long int val = *(ms.begin());
        if (val >= 0) ans[i] += val;
      }
      ms.clear();
      for (i = sz; i > 0; i--) {
        ms.insert(a[i]);
        if (ma >= 0) ans[w + i - sz] -= ma;
        long long int val = *(ms.begin());
        if (val >= 0) ans[w + i - sz] += val;
      }
    } else {
      multiset<long long int, greater<long long int> > ms;
      for (i = 1; i <= w; i++) {
        if (i > w - sz + 1 && (i - (w - sz + 1)) <= sz)
          ms.erase(ms.find(a[i - (w - sz + 1)]));
        if (i <= sz) ms.insert(a[i]);
        long long int val = *(ms.begin());
        if (val >= 0 || (i >= w - sz + 1 && i <= sz)) ans[i] += val;
      }
    }
  }
  for (i = 1; i <= w; i++) {
    ans[i] += offset;
    cout << ans[i] << " ";
  }
  return 0;
}