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 S, class T>
pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) {
  return pair<S, T>(s.first + t.first, s.second + t.second);
}
template <class S, class T>
pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) {
  return pair<S, T>(s.first - t.first, s.second - t.second);
}
template <class S, class T>
ostream &operator<<(ostream &os, pair<S, T> p) {
  os << "(" << p.first << ", " << p.second << ")";
  return os;
}
template <class T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
const long long inf = 1000000001;
const long long INF = (long long)1e18 + 1;
const long long MOD = 1000000007;
const double pi = 3.14159265358979323846;
int dx[4] = {-1, 0, 1, 0}, dy[4] = {0, 1, 0, -1};
int dx2[8] = {1, 1, 0, -1, -1, -1, 0, 1}, dy2[8] = {0, 1, 1, 1, 0, -1, -1, -1};
class LazySegmentTree {
 public:
  int n;
  vector<long long> node, lazy;
  LazySegmentTree(vector<long long> a) {
    int _n = a.size();
    n = 1;
    while (n < _n) n *= 2;
    node.resize(2 * n - 1);
    lazy.resize(2 * n - 1);
    for (int i = 0; i < _n; i++) node[i + n - 1] = a[i];
    for (int i = n - 2; i >= 0; i--) {
      node[i] = node[i * 2 + 1] + node[i * 2 + 2];
    }
  }
  inline void eval(int k, int l, int r) {
    if (lazy[k] != 0) {
      node[k] += (r - l) * lazy[k];
      if (r - l > 1) {
        lazy[2 * k + 1] += lazy[k];
        lazy[2 * k + 2] += lazy[k];
      }
      lazy[k] = 0;
    }
  }
  void add(int a, int b, long long x, int k, int l, int r) {
    eval(k, l, r);
    if (b <= l || r <= a) return;
    if (a <= l && r <= b) {
      lazy[k] += x;
      eval(k, l, r);
    } else {
      add(a, b, x, 2 * k + 1, l, (l + r) / 2);
      add(a, b, x, 2 * k + 2, (l + r) / 2, r);
      node[k] = node[2 * k + 1] + node[2 * k + 2];
    }
  }
  long long getsum(int a, int b, int k, int l, int r) {
    eval(k, l, r);
    if (b <= l || r <= a) return 0;
    if (a <= l && r <= b) return node[k];
    long long resl = getsum(a, b, 2 * k + 1, l, (l + r) / 2);
    long long resr = getsum(a, b, 2 * k + 2, (l + r) / 2, r);
    return resl + resr;
  }
};
vector<pair<int, int> > cover(vector<pair<int, int> > lrl,
                              pair<int, int> zero) {
  vector<pair<int, int> > res;
  for (int i = 0; i < (lrl.size()); i++) {
    pair<int, int> lr = lrl[i];
    if (lr.first >= zero.second) {
      res.push_back(lr);
    } else if (lr.second <= zero.first) {
      res.push_back(lr);
    } else if (zero.first <= lr.first and lr.second <= zero.second) {
      continue;
    } else if (lr.first <= zero.first and zero.second <= lr.second) {
      res.push_back(pair<int, int>(lr.first, zero.first));
      res.push_back(pair<int, int>(zero.second, lr.second));
    } else if ((zero.first <= lr.first && lr.first < zero.second)) {
      lr.first = zero.second;
      res.push_back(lr);
    }
    if ((zero.first <= lr.second && lr.second < zero.second)) {
      lr.second = zero.first;
      res.push_back(lr);
    }
  }
  return res;
}
vector<pair<int, int> > merge_lr(vector<pair<int, int> > lrl) {
  if (lrl.size() == 0) {
    return lrl;
  }
  sort(lrl.begin(), lrl.end());
  vector<pair<int, int> > res;
  for (int i = 0; i < (lrl.size()); i++) {
    pair<int, int> lr = lrl[i];
    if (res.size() == 0)
      res.push_back(lr);
    else {
      if (res.back().second >= lr.first) {
        chmax(res[res.size() - 1].second, lr.second);
      } else {
        res.push_back(lr);
      }
    }
  }
  return res;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ;
  int q, w;
  cin >> q >> w;
  vector<long long> temp(w);
  LazySegmentTree lst(temp);
  using P = pair<long long, pair<int, int> >;
  priority_queue<P> pq;
  for (int i = 0; i < (q); i++) {
    int n;
    cin >> n;
    for (int j = 0; j < (n); j++) {
      long long x;
      cin >> x;
      pq.push(make_pair(x, pair<int, int>(j, j + w - n + 1)));
    }
    vector<pair<int, int> > zero;
    if (n <= w / 2) {
      zero.push_back(pair<int, int>(0, w));
    } else {
      zero.push_back(pair<int, int>(0, w - n));
      zero.push_back(pair<int, int>(n, w));
    }
    set<pair<int, int> > st;
    while (pq.size() > 0) {
      auto temp = pq.top();
      pq.pop();
      long long x = temp.first;
      pair<int, int> lr = temp.second;
      pair<int, int> lr2 = lr;
      auto itr = st.lower_bound(lr);
      while (itr != st.end()) {
        int nl = itr->first;
        if (nl >= lr2.second)
          break;
        else
          lr2.second = nl;
      }
      itr = st.lower_bound(lr);
      while (itr != st.begin()) {
        itr--;
        int pr = itr->second;
        if (pr <= lr2.first)
          break;
        else
          lr2.first = pr;
      }
      if (x < 0) {
        vector<pair<int, int> > lr3(1, lr2);
        for (int i = 0; i < (zero.size()); i++) {
          lr3 = cover(lr3, zero[i]);
        }
        lr3 = merge_lr(lr3);
        for (int i = 0; i < (lr3.size()); i++) {
          if (lr3[i].first < lr3[i].second) {
            lst.add(lr3[i].first, lr3[i].second, x, 0, 0, lst.n);
          }
        }
      } else {
        if (lr2.first < lr2.second) {
          lst.add(lr2.first, lr2.second, x, 0, 0, lst.n);
        }
      }
      st.insert(lr);
    }
  }
  for (int i = 0; i < (w); i++) {
    cout << lst.getsum(i, i + 1, 0, 0, lst.n) << " ";
  }
  cout << endl;
}