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 N;
long long A[1000005];
long long tree[4 * 1000005];
long long lazy[4 * 1000005];
long long b[1000005];
long long tree1[4 * 1000005];
void build_tree(long long node, long long a, long long b) {
  if (a > b) return;
  if (a == b) {
    tree[node] = A[a];
    return;
  }
  build_tree(node * 2, a, (a + b) / 2);
  build_tree(node * 2 + 1, 1 + (a + b) / 2, b);
  tree[node] = max(tree[node * 2], tree[node * 2 + 1]);
}
void build1(long long node, long long a, long long b1) {
  if (a > b1) return;
  if (a == b1) {
    tree1[node] = b[a];
    return;
  }
  build1(node * 2, a, (a + b1) / 2);
  build1(node * 2 + 1, 1 + (a + b1) / 2, b1);
  tree1[node] = max(tree1[node * 2], tree1[node * 2 + 1]);
}
void update_tree(long long node, long long a, long long b, long long i,
                 long long j, long long value) {
  if (lazy[node] != 0) {
    tree[node] += lazy[node] * (b - a + 1);
    if (a != b) {
      lazy[node * 2] += lazy[node];
      lazy[node * 2 + 1] += lazy[node];
    }
    lazy[node] = 0;
  }
  if (a > b || a > j || b < i) return;
  if (a >= i && b <= j) {
    tree[node] += value * (b - a + 1);
    if (a != b) {
      lazy[node * 2] += value;
      lazy[node * 2 + 1] += value;
    }
    return;
  }
  if (a == b) return;
  update_tree(node * 2, a, (a + b) / 2, i, j, value);
  update_tree(1 + node * 2, 1 + (a + b) / 2, b, i, j, value);
  tree[node] = max(tree[node * 2], tree[node * 2 + 1]);
}
long long query_tree(long long node, long long a, long long b, long long i,
                     long long j) {
  if (lazy[node] != 0) {
    tree[node] += lazy[node] * (b - a + 1);
    if (a != b) {
      lazy[node * 2] += lazy[node];
      lazy[node * 2 + 1] += lazy[node];
    }
    lazy[node] = 0;
  }
  if (a > b || a > j || b < i) return -10000000000000;
  if (a >= i && b <= j) return tree[node] * (j - i + 1);
  long long q1 = query_tree(node * 2, a, (a + b) / 2, i, j);
  long long q2 = query_tree(1 + node * 2, 1 + (a + b) / 2, b, i, j);
  long long res = max(q1, q2);
  return res;
}
long long query(long long node, long long start, long long end, long long l,
                long long r) {
  if (r < start || end < l) {
    return -10000000000000;
  }
  if (l <= start && end <= r) {
    return tree1[node];
  }
  long long mid = (start + end) / 2;
  long long p1 = query(2 * node, start, mid, l, r);
  long long p2 = query(2 * node + 1, mid + 1, end, l, r);
  return max(p1, p2);
}
long long ans[1000005];
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long n, m;
  cin >> n >> m;
  swap(n, m);
  long long xxx = (n + 1) / 2;
  while (m--) {
    long long len;
    cin >> len;
    vector<long long> a(len);
    long long xx = 0;
    for (long long i = 0; i < len; i++) {
      cin >> a[i];
      xx = max(xx, a[i]);
    }
    if (len >= xxx) {
      for (long long i = 1; i <= len; i++) {
        b[i] = a[i - 1];
      }
      build1(1, 1, len);
      for (long long i = 1; i <= n; i++) {
        long long r1 = min(i, len);
        long long d = (n - i + 1);
        long long l1;
        if (d < len)
          l1 = len - d + 1;
        else
          l1 = 1;
        long long qq = query(1, 1, len, l1, r1);
        if (i > len || i <= (n - len)) qq = max(0ll, qq);
        ans[i] += qq;
      }
      continue;
    }
    long long pre = 0;
    long long mini = a[0];
    for (long long i = 1; i <= len; i++) {
      if ((i + len - 1) > n) break;
      pre++;
      mini = max(mini, a[i - 1]);
      if (i > len || i <= (n - len)) mini = max(mini, 0ll);
      ans[i] += mini;
    }
    long long suff = n + 1;
    mini = a[len - 1];
    long long cur = len;
    for (long long i = n; i >= n - len + 1; i--) {
      if ((i - len + 1) < 1 || suff <= pre || cur == 0) break;
      suff = i;
      mini = max(mini, a[cur - 1]);
      if (i > len || i <= (n - len)) mini = max(mini, 0ll);
      cur--;
      ans[i] += mini;
    }
    xx = max(xx, 0ll);
    if (pre + 1 > suff - 1) {
      while (1) {
        ;
      }
    }
    if (pre + 1 <= suff - 1) update_tree(1, 1, n, pre + 1, suff - 1, xx);
  }
  for (long long i = 1; i <= n; i++) {
    cout << ans[i] + query_tree(1, 1, n, i, i) << " ";
  }
  cout << endl;
  return 0;
}