You are given n non-decreasing arrays of non-negative numbers. 

Vasya repeats the following operation k times: 

  * Selects a non-empty array. 
  * Puts the first element of the selected array in his pocket. 
  * Removes the first element from the selected array. 



Vasya wants to maximize the sum of the elements in his pocket.

Input

The first line contains two integers n and k (1 ≤ n, k ≤ 3 000): the number of arrays and operations.

Each of the next n lines contain an array. The first integer in each line is t_i (1 ≤ t_i ≤ 10^6): the size of the i-th array. The following t_i integers a_{i, j} (0 ≤ a_{i, 1} ≤ … ≤ a_{i, t_i} ≤ 10^8) are the elements of the i-th array.

It is guaranteed that k ≤ ∑_{i=1}^n t_i ≤ 10^6.

Output

Print one integer: the maximum possible sum of all elements in Vasya's pocket after k operations.

Example

Input


3 3
2 5 10
3 1 2 3
2 1 20


Output


26
#include <bits/stdc++.h>
using namespace std;
const int N = 3005;
using ll = long long;
int n, k;
vector<ll> vecs[N];
ll sum[N];
ll ans;
void add(vector<ll> &ks, ll val, int weight) {
  for (int i = (int)ks.size() - 1; i >= weight; i--) {
    ks[i] = max(ks[i], ks[i - weight] + val);
  }
}
void solve(int L, int R, const vector<ll> &ks) {
  if (L == R) {
    ans = max(ans, ks.back());
    vector<ll> &vec = vecs[L];
    ll local = 0;
    for (int i = 0; i < (int)vec.size(); i++) {
      local += vec[i];
      ans = max(ans, local + ks[k - i - 1]);
    }
    return;
  }
  int mid = (L + R) / 2;
  vector<ll> left = ks;
  for (int i = mid + 1; i <= R; i++) {
    add(left, sum[i], (int)vecs[i].size());
  }
  solve(L, mid, left);
  vector<ll> right = ks;
  for (int i = L; i <= mid; i++) {
    add(right, sum[i], (int)vecs[i].size());
  }
  solve(mid + 1, R, right);
}
int main() {
  scanf("%d %d", &n, &k);
  for (int i = 0; i < n; i++) {
    int sz;
    scanf("%d", &sz);
    vecs[i].resize(sz);
    for (ll &x : vecs[i]) scanf("%lld", &x);
    if ((int)vecs[i].size() > k) vecs[i].resize(k);
    sum[i] = accumulate(vecs[i].begin(), vecs[i].end(), 0LL);
  }
  solve(0, n - 1, vector<ll>(k + 1, 0));
  printf("%lld\n", ans);
}
