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 long long maxm = 3e3 + 5;
long long w[maxm][maxm];
long long t[maxm];
long long d[maxm];
long long n, k;
long long ans;
void solve(long long l, long long r) {
  if (l == r) {
    for (long long i = 0; i <= t[l]; i++) {
      ans = max(ans, w[l][i] + d[k - i]);
    }
    return;
  }
  long long mid = (l + r) / 2;
  long long f[maxm];
  for (long long i = 0; i <= k; i++) f[i] = d[i];
  for (long long i = mid + 1; i <= r; i++) {
    for (long long j = k; j >= t[i]; j--) {
      d[j] = max(d[j], d[j - t[i]] + w[i][t[i]]);
    }
  }
  solve(l, mid);
  for (long long i = 0; i <= k; i++) d[i] = f[i];
  for (long long i = l; i <= mid; i++) {
    for (long long j = k; j >= t[i]; j--) {
      d[j] = max(d[j], d[j - t[i]] + w[i][t[i]]);
    }
  }
  solve(mid + 1, r);
}
signed main() {
  ios::sync_with_stdio(0);
  cin >> n >> k;
  for (long long i = 1; i <= n; i++) {
    cin >> t[i];
    for (long long j = 1; j <= t[i]; j++) {
      long long x;
      cin >> x;
      if (j <= k) {
        w[i][j] = w[i][j - 1] + x;
      }
    }
    t[i] = min(t[i], k);
  }
  solve(1, n);
  cout << ans << endl;
  return 0;
}
