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 maxn = 3005;
long long dp[22][maxn];
vector<long long> a[maxn], pre[maxn];
long long tot[maxn];
int n, k;
long long ans = 0;
void solve(int l, int r, int floor) {
  if (l == r) {
    for (int i = k - 1; i >= max(0, k - (int)a[l].size()); i--) {
      int delta = k - i;
      ans = max(ans, dp[floor][i] + pre[l][delta - 1]);
    }
    for (int i = (0), iend = (k); i <= iend; i++) ans = max(ans, dp[floor][i]);
    return;
  }
  int mid = (l + r) >> 1;
  memcpy(dp[floor + 1], dp[floor], sizeof(dp[floor + 1]));
  for (int i = (mid + 1), iend = (r); i <= iend; i++) {
    for (int c = k - a[i].size(); c >= 0; c--) {
      dp[floor + 1][c + a[i].size()] =
          max(dp[floor + 1][c + a[i].size()], dp[floor + 1][c] + tot[i]);
    }
  }
  solve(l, mid, floor + 1);
  memcpy(dp[floor + 1], dp[floor], sizeof(dp[floor + 1]));
  for (int i = (l), iend = (mid); i <= iend; i++) {
    for (int c = k - a[i].size(); c >= 0; c--) {
      dp[floor + 1][c + a[i].size()] =
          max(dp[floor + 1][c + a[i].size()], dp[floor + 1][c] + tot[i]);
    }
  }
  solve(mid + 1, r, floor + 1);
}
int main() {
  scanf("%d%d", &n, &k);
  for (int i = (1), iend = (n); i <= iend; i++) {
    int t;
    scanf("%d", &t);
    long long last = 0;
    for (int j = (1), jend = (t); j <= jend; j++) {
      long long val;
      scanf("%lld", &val);
      last += val;
      a[i].push_back(val);
      pre[i].push_back(last);
    }
    tot[i] = last;
  }
  solve(1, n, 1);
  cout << ans;
}
