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;
long long f[3005], val[3005], ans;
vector<int> a[3005];
int siz[3005], m;
void solve(int l, int r) {
  if (l == r) {
    int i;
    long long cnt = 0;
    for (i = 0; i <= siz[l]; ++i)
      cnt += a[l][i], ans = max(ans, f[m - i] + cnt);
    return;
  }
  int mid = l + r >> 1, i, j;
  long long tmp[3005];
  for (i = 0; i <= m; ++i) tmp[i] = f[i];
  for (i = l; i <= mid; ++i)
    for (j = m; j >= siz[i]; --j) f[j] = max(f[j], f[j - siz[i]] + val[i]);
  solve(mid + 1, r);
  for (i = 0; i <= m; ++i) f[i] = tmp[i];
  for (i = mid + 1; i <= r; ++i)
    for (j = m; j >= siz[i]; --j) f[j] = max(f[j], f[j - siz[i]] + val[i]);
  solve(l, mid);
}
int main() {
  int n, i, j, x;
  scanf("%d%d", &n, &m);
  for (i = 1; i <= n; ++i) {
    scanf("%d", &siz[i]), a[i].reserve(siz[i] + 1), a[i].push_back(0);
    for (j = 1; j <= siz[i]; ++j) scanf("%d", &x), a[i].push_back(x);
  }
  for (i = 1; i <= n; ++i)
    if (siz[i] > m) siz[i] = m;
  for (i = 1; i <= n; ++i)
    for (j = 1; j <= siz[i]; ++j) val[i] += a[i][j];
  solve(1, n), printf("%lld\n", ans);
  return 0;
}
