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;
long long t[4000000];
long long t1[4000000];
long long t2[4000000];
long long lz[4000000];
long long ans[4000000];
long long dis[4000000];
long long p[4000000];
long long dp[708 + 5][708 + 5];
vector<pair<long long, long long> > v;
vector<int> v1;
long long n, m, k, l, r, nb, q;
set<pair<long long, long long> > st;
map<int, int> mapp;
map<int, int> mapp2;
map<pair<long long, long long>, int> mapp3;
void update(int node, int l1, int r1, int l, int r, long long val) {
  if ((l1 > r) || (r1 < l)) return;
  if ((l <= l1) && (r1 <= r)) {
    lz[node] += val;
    return;
  }
  int mid = (l1 + r1) / 2;
  update(2 * node, l1, mid, l, r, val);
  update(2 * node + 1, mid + 1, r1, l, r, val);
}
void debugst() {
  cout << "debugging st \n";
  set<pair<long long, long long> >::iterator it;
  for (it = st.begin(); it != st.end(); it++)
    cout << it->first << "," << it->second << '\n';
  cout << '\n';
}
void debugt() {
  cout << "debug t \n";
  for (int i = 0; i < m; i++) cout << t[i] << " ";
  cout << '\n';
}
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n >> m;
  nb = m - 1;
  int cnt = 0;
  while (nb) nb >>= 1, cnt++;
  nb = (1 << cnt);
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    for (int i = 0; i < a; i++) cin >> t[i];
    if (a > m / 2) {
      t1[m - 1] = t[a - 1];
      st.clear();
      for (int i = 0; i < a; i++) {
        st.insert(make_pair(t[i], i));
        t1[i] = (st.rbegin())->first;
        if (i >= m - a) st.erase(make_pair(t[i - (m - a)], i - m + a));
      }
      for (int i = a; i < m - 1; i++) {
        t1[i] = (st.rbegin())->first;
        st.erase(make_pair(t[i - (m - a)], i - m + a));
      }
      for (int i = 0; i < m - a; i++) t1[i] = max(t1[i], 0ll);
      for (int i = a; i < m; i++) t1[i] = max(t1[i], 0ll);
      for (int i = 0; i < m; i++) ans[i] += t1[i];
    } else {
      long long maax = 0;
      for (int i = 0; i < a; i++) {
        maax = max(maax, t[i]);
        ans[i] += maax;
      }
      maax = 0;
      for (int i = m - 1; i > m - 1 - a; i--) {
        maax = max(maax, t[i - (m - a)]);
        ans[i] += maax;
      }
      update(1, 0, nb - 1, a, m - 1 - a, maax);
    }
  }
  for (int i = 1; i <= nb; i++) {
    lz[2 * i] += lz[i];
    lz[2 * i + 1] += lz[i];
  }
  for (int i = 0; i < m; i++) cout << lz[nb + i] + ans[i] << " ";
}