#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vb = vector<bool>;
using vvi = vector<vector<int>>;
using vll = vector<long long>;
using vpi = vector<pair<int, int>>;
using pii = pair<int, int>;
const char nl = '\n';
string to_string(char c) { return string(1, c); }
string to_string(const char* s) { return (string)s; }
string to_string(string s) { return s; }
string to_string(bool b) { return b ? "true" : "false"; }
string to_string(vector<bool> v) {
  string res = "{";
  for (int i = 0; i < ((int)v.size()); ++i) res += char('0' + v[i]);
  res += "}";
  return res;
}
template <size_t SZ>
string to_string(bitset<SZ> b) {
  string res = "";
  for (int i = 0; i < (SZ); ++i) res += char('0' + b[i]);
  return res;
}
template <class A, class B>
string to_string(pair<A, B> p);
template <class T>
string to_string(T& v) {
  bool fst = 1;
  string res = "{";
  for (const auto& x : v) {
    if (!fst) res += ", ";
    fst = 0;
    res += to_string(x);
  }
  res += "}";
  return res;
}
template <class A, class B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
void DBG() { cerr << "]" << endl; }
template <class H, class... T>
void DBG(H h, T... t) {
  cerr << to_string(h);
  if (sizeof...(t)) cerr << ", ";
  DBG(t...);
}
struct Seg {
  int n;
  vector<ll> seg;
  Seg(int n) : n(n), seg(4 * n) {}
  void update(int pos, int val, int idx, int L, int R) {
    if (L == R) {
      seg[idx] = val;
    } else {
      int M = (L + R) / 2;
      if (pos <= M)
        update(pos, val, idx * 2, L, M);
      else
        update(pos, val, idx * 2 + 1, M + 1, R);
      seg[idx] = seg[idx * 2] + seg[idx * 2 + 1];
    }
  }
  void update(int pos, int val) { update(pos, val, 1, 0, n - 1); }
  ll query(int lo, int hi, int idx, int L, int R) {
    if (lo > hi) return 0;
    if (L == lo && hi == R) return seg[idx];
    int M = (L + R) / 2;
    return query(lo, min(hi, M), idx * 2, L, M) +
           query(max(lo, M + 1), hi, idx * 2 + 1, M + 1, R);
  }
  ll query(int lo, int hi) { return query(lo, hi, 1, 0, n - 1); }
};
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  struct event {
    int t, ar, val, type;
    event(int t, int ar, int val, int type)
        : t(t), ar(ar), val(val), type(type) {}
    bool operator<(const event& e) const {
      if (t == e.t) {
        return type < e.type;
      }
      return t < e.t;
    }
  };
  int n, w;
  cin >> n >> w;
  vector<event> evs;
  for (int i = 0; i < n; i++) {
    int l;
    cin >> l;
    for (int j = 0; j < l; j++) {
      int a;
      cin >> a;
      evs.emplace_back(j, i, a, 1);
      evs.emplace_back(w - l + j + 1, i, a, -1);
    }
    if (l < w) {
      evs.emplace_back(0, i, 0, 1);
      evs.emplace_back(w, i, 0, -1);
      if (l > w - l) {
        evs.emplace_back(w - l, i, 0, -1);
        evs.emplace_back(l, i, 0, 1);
      }
    }
  }
  sort(evs.begin(), evs.end());
  Seg seg(n + 1);
  vector<multiset<int>> els(n);
  vector<ll> res(w);
  int i = 0;
  for (int t = 0; t < w; t++) {
    0;
    while (i < evs.size() && evs[i].t == t) {
      auto& e = evs[i];
      0;
      if (e.type == 1) {
        els[e.ar].insert(e.val);
      } else {
        els[e.ar].erase(els[e.ar].lower_bound(e.val));
      }
      if (els[e.ar].size() > 0) {
        seg.update(e.ar, *els[e.ar].rbegin());
      }
      i++;
    }
    res[t] = seg.query(0, n - 1);
  }
  for (ll x : res) {
    cout << x << " ";
  }
  cout << nl;
  return 0;
}

### Prompt

Construct a Cpp code solution to the problem outlined:

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.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vb = vector<bool>;
using vvi = vector<vector<int>>;
using vll = vector<long long>;
using vpi = vector<pair<int, int>>;
using pii = pair<int, int>;
const char nl = '\n';
string to_string(char c) { return string(1, c); }
string to_string(const char* s) { return (string)s; }
string to_string(string s) { return s; }
string to_string(bool b) { return b ? "true" : "false"; }
string to_string(vector<bool> v) {
  string res = "{";
  for (int i = 0; i < ((int)v.size()); ++i) res += char('0' + v[i]);
  res += "}";
  return res;
}
template <size_t SZ>
string to_string(bitset<SZ> b) {
  string res = "";
  for (int i = 0; i < (SZ); ++i) res += char('0' + b[i]);
  return res;
}
template <class A, class B>
string to_string(pair<A, B> p);
template <class T>
string to_string(T& v) {
  bool fst = 1;
  string res = "{";
  for (const auto& x : v) {
    if (!fst) res += ", ";
    fst = 0;
    res += to_string(x);
  }
  res += "}";
  return res;
}
template <class A, class B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
void DBG() { cerr << "]" << endl; }
template <class H, class... T>
void DBG(H h, T... t) {
  cerr << to_string(h);
  if (sizeof...(t)) cerr << ", ";
  DBG(t...);
}
struct Seg {
  int n;
  vector<ll> seg;
  Seg(int n) : n(n), seg(4 * n) {}
  void update(int pos, int val, int idx, int L, int R) {
    if (L == R) {
      seg[idx] = val;
    } else {
      int M = (L + R) / 2;
      if (pos <= M)
        update(pos, val, idx * 2, L, M);
      else
        update(pos, val, idx * 2 + 1, M + 1, R);
      seg[idx] = seg[idx * 2] + seg[idx * 2 + 1];
    }
  }
  void update(int pos, int val) { update(pos, val, 1, 0, n - 1); }
  ll query(int lo, int hi, int idx, int L, int R) {
    if (lo > hi) return 0;
    if (L == lo && hi == R) return seg[idx];
    int M = (L + R) / 2;
    return query(lo, min(hi, M), idx * 2, L, M) +
           query(max(lo, M + 1), hi, idx * 2 + 1, M + 1, R);
  }
  ll query(int lo, int hi) { return query(lo, hi, 1, 0, n - 1); }
};
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  struct event {
    int t, ar, val, type;
    event(int t, int ar, int val, int type)
        : t(t), ar(ar), val(val), type(type) {}
    bool operator<(const event& e) const {
      if (t == e.t) {
        return type < e.type;
      }
      return t < e.t;
    }
  };
  int n, w;
  cin >> n >> w;
  vector<event> evs;
  for (int i = 0; i < n; i++) {
    int l;
    cin >> l;
    for (int j = 0; j < l; j++) {
      int a;
      cin >> a;
      evs.emplace_back(j, i, a, 1);
      evs.emplace_back(w - l + j + 1, i, a, -1);
    }
    if (l < w) {
      evs.emplace_back(0, i, 0, 1);
      evs.emplace_back(w, i, 0, -1);
      if (l > w - l) {
        evs.emplace_back(w - l, i, 0, -1);
        evs.emplace_back(l, i, 0, 1);
      }
    }
  }
  sort(evs.begin(), evs.end());
  Seg seg(n + 1);
  vector<multiset<int>> els(n);
  vector<ll> res(w);
  int i = 0;
  for (int t = 0; t < w; t++) {
    0;
    while (i < evs.size() && evs[i].t == t) {
      auto& e = evs[i];
      0;
      if (e.type == 1) {
        els[e.ar].insert(e.val);
      } else {
        els[e.ar].erase(els[e.ar].lower_bound(e.val));
      }
      if (els[e.ar].size() > 0) {
        seg.update(e.ar, *els[e.ar].rbegin());
      }
      i++;
    }
    res[t] = seg.query(0, n - 1);
  }
  for (ll x : res) {
    cout << x << " ";
  }
  cout << nl;
  return 0;
}

```