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 n, K, dx[3010];
long long he[3010], maxx, ddpp[3010];
vector<long long> ysl[3010];
void fz(long long l, long long r, long long dp[3010]) {
  if (l == r) {
    long long sm = 0;
    for (long long i = 0; i <= dx[l] && i <= K; i++) {
      if (i != 0) sm += ysl[l][i - 1];
      maxx = max(maxx, dp[K - i] + sm);
    }
    return;
  }
  long long mid = (l + r) >> 1;
  long long dpp[3010];
  for (long long i = 0; i <= K; i++) dpp[i] = dp[i];
  for (long long i = mid + 1; i <= r; i++) {
    for (long long j = K; j >= dx[i]; j--) {
      dpp[j] = max(dpp[j], dpp[j - dx[i]] + he[i]);
    }
  }
  fz(l, mid, dpp);
  for (long long i = 0; i <= K; i++) dpp[i] = dp[i];
  for (long long i = l; i <= mid; i++) {
    for (long long j = K; j >= dx[i]; j--) {
      dpp[j] = max(dpp[j], dpp[j - dx[i]] + he[i]);
    }
  }
  fz(mid + 1, r, dpp);
  return;
}
signed main() {
  scanf("%lld%lld", &n, &K);
  for (long long i = 1; i <= n; i++) {
    long long x;
    scanf("%lld", &x);
    dx[i] = x;
    for (long long j = 1; j <= x; j++) {
      long long y;
      scanf("%lld", &y);
      ysl[i].push_back(y);
      he[i] += y;
    }
  }
  fz(1, n, ddpp);
  cout << maxx;
  return 0;
}
