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;
inline long long read() {
  char ch = getchar();
  long long nega = 1;
  while (!isdigit(ch)) {
    if (ch == '-') nega = -1;
    ch = getchar();
  }
  long long ans = 0;
  while (isdigit(ch)) {
    ans = ans * 10 + ch - 48;
    ch = getchar();
  }
  if (nega == -1) return -ans;
  return ans;
}
vector<long long> v[1000005];
long long a[1000005];
long long ans[1000005];
long long l[1000005], r[1000005], res[1000005];
long long c[1000005];
struct Node {
  long long pl, dat;
};
signed main() {
  long long n, m;
  cin >> n >> m;
  for (long long i = 1; i <= n; i++) {
    a[i] = read();
    v[i].push_back(a[i]);
    for (long long j = 0; j < a[i]; j++) {
      long long x = read();
      v[i].push_back(x);
      if (res[i] < x) res[i] = x;
    }
  }
  for (long long i = 1; i <= n; i++) {
    l[i] = a[i], r[i] = m - a[i] + 1;
    if (a[i] == m) {
      for (long long j = 1; j <= a[i]; j++) {
        ans[j] += v[i][j];
      }
      continue;
    }
    if (l[i] > r[i]) {
      deque<Node> q;
      for (long long j = 1; j <= m; j++) {
        if (j <= a[i]) {
          while (!q.empty() && v[i][j] > q.back().dat) q.pop_back();
        }
        while (!q.empty() && q.front().pl < j + a[i] - m) q.pop_front();
        if (j <= a[i]) q.push_back((Node){j, v[i][j]});
        if (j > l[i] || j < r[i])
          ans[j] += max(q.front().dat, 0LL);
        else
          ans[j] += q.front().dat;
      }
    } else if (l[i] < r[i]) {
      long long pre = 0;
      for (long long j = 1; j <= a[i]; j++) {
        if (v[i][j] > pre) pre = v[i][j];
        ans[j] += pre;
      }
      pre = 0;
      for (long long j = m, k = 1; j >= m - a[i] + 1; j--, k++) {
        if (v[i][a[i] - k + 1] > pre) pre = v[i][a[i] - k + 1];
        ans[j] += pre;
      }
      c[l[i] + 1] += res[i], c[r[i]] -= res[i];
    } else {
      long long pre = 0;
      for (long long j = 1; j <= a[i]; j++) {
        if (v[i][j] > pre) pre = v[i][j];
        ans[j] += pre;
      }
      pre = 0;
      for (long long j = m, k = 1; j > m - a[i] + 1; j--, k++) {
        if (v[i][a[i] - k + 1] > pre) pre = v[i][a[i] - k + 1];
        ans[j] += pre;
      }
    }
  }
  long long tmp = 0;
  for (long long i = 1; i <= m; i++) {
    tmp += c[i];
    printf("%lld ", tmp + ans[i]);
  }
  cout << "\n";
  return 0;
}