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;
template <class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
  os << "(" << p.first << ", " << p.second << ")";
  return os;
}
template <class T, class U>
ostream& operator<<(ostream& os, const map<T, U>& mp) {
  os << "{";
  int i = 0;
  for (auto it : mp) {
    if (i) os << ", ";
    os << it;
    i++;
  }
  os << "}";
  return os;
}
template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
  os << "{";
  for (int i = 0; i < (int)v.size(); i++) {
    if (i) os << ", ";
    os << v[i];
  }
  os << "}";
  return os;
}
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << " : " << arg1 << " | ";
  __f(comma + 1, args...);
}
const int N = 1000006;
const int INF = 1e9 + 10;
struct segtree {
  vector<int> tree;
  int n;
  segtree() {}
  segtree(int _n) {
    n = _n;
    tree.resize(4 * n + 5);
  }
  void update(int i, int val, int s, int e, int ind = 1) {
    if (s > i || e < i) return;
    if (s == e) {
      tree[ind] = val;
      return;
    }
    int mid = (s + e) >> 1;
    update(i, val, s, mid, ind << 1);
    update(i, val, mid + 1, e, ind << 1 | 1);
    tree[ind] = max(tree[ind << 1], tree[ind << 1 | 1]);
  }
  int get_max(int l, int r, int s, int e, int ind = 1) {
    if (s > r || e < l) return -INF;
    if (s >= l && e <= r) return tree[ind];
    int mid = (s + e) >> 1;
    return max(get_max(l, r, s, mid, ind << 1),
               get_max(l, r, mid + 1, e, ind << 1 | 1));
  }
  void update(int i, int v) { update(i, v, 1, n); }
  int get_max(int l, int r) { return get_max(l, r, 1, n); }
};
segtree st[N];
vector<int> positions[N];
int mx[N];
int l[N];
int n, w;
int get(int i, int pos) {
  int L = l[i];
  int ret = -INF;
  if (pos > l[i] || pos <= w - l[i]) ret = 0;
  int mn = max(1, l[i] - w + pos);
  int mx = min(pos, l[i]);
  return max(ret, st[i].get_max(mn, mx));
}
int main() {
  scanf("%d", &(n));
  scanf("%d", &(w));
  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &(l[i]));
    st[i] = segtree(l[i]);
    for (int j = 1; j <= l[i]; j++) {
      int x;
      scanf("%d", &(x));
      st[i].update(j, x);
      mx[i] = max(mx[i], x);
    }
    ans += mx[i];
    for (int j = 1; j <= l[i]; j++) positions[j].push_back(i);
    for (int j = max(l[i] + 1, w - l[i] + 1); j <= w; j++)
      positions[j].push_back(i);
  }
  for (int i = 1; i <= w; i++) {
    long long val = ans;
    for (int j : positions[i]) {
      val -= mx[j];
      val += get(j, i);
    }
    printf("%lld ", val);
  }
}