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;
namespace letemslide {
vector<vector<int> > arr;
int nay, N, n, w;
vector<long long> a, t, lazy;
void build() {
  n = 1;
  while (n < N) n *= 2;
  t = vector<long long>(2 * n, 0);
  lazy = vector<long long>(2 * n, 0);
  for (int i = 0; i < 2 * n; i++) {
    t[i] = 0;
  }
}
void push(int v, int len) {
  t[v] += lazy[v] * len;
  if (v < n) {
    lazy[v * 2] += lazy[v];
    lazy[v * 2 + 1] += lazy[v];
  }
  lazy[v] = 0;
}
long long sum(int v, int tl, int tr, int l, int r) {
  push(v, tr - tl + 1);
  if (l > r) return 0;
  if (l <= tl && tr <= r) return t[v];
  int tm = (tl + tr) / 2;
  return sum(v * 2, tl, tm, l, min(r, tm)) +
         sum(v * 2 + 1, tm + 1, tr, max(l, tm + 1), r);
}
long long sum(int l, int r) { return sum(1, 0, n - 1, l, r); }
void update(int v, int tl, int tr, int pos, int incr) {
  push(v, tr - tl + 1);
  if (tl == tr) {
    lazy[v] += incr;
  } else {
    int tm = (tl + tr) / 2;
    push(v, tr - tl + 1);
    if (pos <= tm)
      update(v * 2, tl, tm, pos, incr);
    else
      update(v * 2 + 1, tm + 1, tr, pos, incr);
    t[v] = t[v * 2] + t[v * 2 + 1];
  }
}
void update(int pos, int incr) { update(1, 0, n - 1, pos, incr); }
static void update(int v, int tl, int tr, int l, int r, long long add) {
  push(v, tr - tl + 1);
  if (l > r) return;
  if (l <= tl && tr <= r) {
    lazy[v] += add;
    push(v, tr - tl + 1);
    return;
  }
  int tm = (tl + tr) / 2;
  update(v * 2, tl, tm, l, min(r, tm), add);
  update(v * 2 + 1, tm + 1, tr, max(l, tm + 1), r, add);
  t[v] = t[v * 2] + t[v * 2 + 1];
}
static void update(int l, int r, long long add) {
  if (add == 0) {
    return;
  }
  update(1, 0, n - 1, l, r, add);
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> nay >> w;
  arr.resize(nay);
  a.resize(w);
  N = 0;
  for (int i = 0; i < nay; i++) {
    int l;
    cin >> l;
    N += l;
    arr[i].resize(l);
    for (int j = 0; j < l; j++) {
      cin >> arr[i][j];
    }
  }
  N = w;
  build();
  for (int i = 0; i < nay; i++) {
    int l = arr[i].size();
    if (w <= 2 * l - 1) {
      multiset<long long> stuff;
      for (int j = 0; j < w - l; j++) {
        stuff.insert(-arr[i][j]);
        long long best = -(*stuff.begin());
        best = max(best, 0LL);
        update(j, best);
      }
      stuff.insert(-arr[i][w - l]);
      long long bestie = -(*stuff.begin());
      update(w - l, bestie);
      for (int j = w - l + 1; j < l; j++) {
        stuff.insert(-arr[i][j]);
        stuff.erase(stuff.find(-arr[i][j - w + l - 1]));
        long long best = -(*stuff.begin());
        update(j, best);
      }
      stuff.clear();
      for (int j = w - 1; j >= l; j--) {
        stuff.insert(-arr[i][l + j - w]);
        long long best = -(*stuff.begin());
        best = max(best, 0LL);
        update(j, best);
      }
    } else {
      multiset<long long> stuff;
      for (int j = 0; j < l; j++) {
        stuff.insert(-arr[i][j]);
        long long best = -(*stuff.begin());
        best = max(best, 0LL);
        update(j, best);
      }
      long long bestie = -(*stuff.begin());
      bestie = max(bestie, 0LL);
      update(l, w - l - 1, bestie);
      stuff.clear();
      for (int j = w - 1; j >= w - l; j--) {
        stuff.insert(-arr[i][l + j - w]);
        long long best = -(*stuff.begin());
        best = max(best, 0LL);
        update(j, best);
      }
    }
  }
  for (int i = 0; i < w; i++) {
    cout << sum(i, i) << " ";
  }
  cout << endl;
  return 0;
}
}  // namespace letemslide
int main() {
  letemslide::main();
  return 0;
}