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;
void fast() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
}
const int INF = 1e9 + 9;
const int N = 1e6 + 5;
vector<long long> segtree(4 * N, 0), lazy(4 * N, 0);
vector<vector<pair<long long, int>>> v(N);
set<pair<int, int>> s;
int n, w;
void spread(int node, int l, int r) {
  if (lazy[node] != 0) {
    segtree[node] += lazy[node];
    if (l != r) {
      lazy[2 * node + 1] += lazy[node];
      lazy[2 * node + 2] += lazy[node];
    }
  }
  lazy[node] = 0;
}
void update(int x, int y, int val, int node = 0, int l = 0, int r = w) {
  spread(node, l, r);
  if (l > y || r < x || x > y) return;
  if (l >= x && r <= y) {
    lazy[node] += val;
    spread(node, l, r);
    return;
  }
  int mid = (l + r) >> 1;
  update(x, y, val, 2 * node + 1, l, mid);
  update(x, y, val, 2 * node + 2, mid + 1, r);
  segtree[node] = segtree[2 * node + 1] + segtree[2 * node + 2];
}
long long query(int x, int y, int node = 0, int l = 0, int r = w) {
  spread(node, l, r);
  if (l > y || r < x || x > y) return 0;
  if (l >= x && r <= y) {
    return segtree[node];
  }
  int mid = (l + r) >> 1;
  return query(x, y, 2 * node + 1, l, mid) +
         query(x, y, 2 * node + 2, mid + 1, r);
}
void add(int l, int r, long long val) {
  auto it = s.lower_bound(make_pair(l, -1));
  if (it != s.begin() && prev(it)->second >= l) it--;
  vector<pair<int, int>> v;
  auto temp = it;
  auto it2 = s.lower_bound(make_pair(r + 1, -1));
  int mn = l, mx = r;
  while (temp != it2) {
    v.push_back(*temp);
    mn = min(mn, temp->first);
    mx = max(mx, temp->second);
    temp++;
  }
  s.erase(it, it2);
  s.insert(make_pair(mn, mx));
  if (v.empty())
    update(l, r, val);
  else {
    update(l, v[0].first - 1, val);
    for (int i = 1; i < v.size(); i++) {
      int l = v[i - 1].second + 1;
      int r = v[i].first - 1;
      update(l, r, val);
    }
    update(v.back().second + 1, r, val);
  }
}
void solve() {
  for (int i = 0; i < n; i++) {
    s.clear();
    int len = v[i].size();
    sort(v[i].rbegin(), v[i].rend());
    for (int j = 0; j < len; j++) {
      int idx = v[i][j].second;
      if (v[i][j].first >= 0) {
        int l = idx, r = idx + w - len;
        add(l, r, v[i][j].first);
      } else {
        if (len * 2 <= w) break;
        int diff = (2 * len - w);
        int x = (w - diff) >> 1;
        int y = (x + diff - 1);
        int l = max(x, idx);
        int r = min(y, idx + w - len);
        add(l, r, v[i][j].first);
      }
    }
  }
  for (int i = 0; i < w; i++) cout << query(i, i) << ' ';
  cout << "\n";
}
int main() {
  fast();
  cin >> n >> w;
  for (int i = 0; i < n; i++) {
    int len;
    cin >> len;
    for (int j = 0; j < len; j++) {
      long long a;
      cin >> a;
      v[i].push_back(make_pair(a, j));
    }
  }
  solve();
}