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 = 3010;
long long dp[N][N];
long long cur[N];
vector<long long> v[N];
int n, k, idx[N];
vector<long long> arr[N];
bool in[N];
void build_path(int i, int j) {
  if (i == n) return;
  if (dp[i + 1][j] == dp[i][j]) {
    in[i] = false;
    build_path(i + 1, j);
  } else {
    in[i] = true;
    idx[(int)arr[i].size()]++;
    build_path(i + 1, j - (int)arr[i].size());
  }
}
int main() {
  scanf("%d%d", &n, &k);
  for (int t, i = 0; i < n; i++) {
    scanf("%d", &t);
    arr[i].resize(t);
    for (int a, j = 0; j < t; j++) {
      scanf("%d", &a);
      cur[i] += a;
      arr[i][j] = cur[i];
    }
    if ((int)arr[i].size() <= k) v[(int)arr[i].size()].push_back(cur[i]);
  }
  for (int i = 1; i <= k; i++) {
    sort(v[i].begin(), v[i].end());
    reverse(v[i].begin(), v[i].end());
  }
  for (int i = 1; i <= k; i++) dp[n][i] = -(long long)1e18;
  for (int i = n - 1; i >= 0; i--) {
    for (int j = 0; j <= k; j++) {
      dp[i][j] = dp[i + 1][j];
      if (j >= (int)arr[i].size())
        dp[i][j] = max(dp[i][j], dp[i + 1][j - (int)arr[i].size()] + cur[i]);
    }
  }
  long long ans = dp[0][k], val;
  for (int sz = 0; sz < k; sz++) {
    val = dp[0][sz];
    for (int j = 1; j <= k; j++) idx[j] = 0;
    build_path(0, sz);
    for (int i = 0; i <= n; i++) {
      if (in[i]) {
        if (idx[(int)arr[i].size()] == (int)v[(int)arr[i].size()].size())
          continue;
        val -= cur[i];
        val += v[(int)arr[i].size()][idx[(int)arr[i].size()]];
        if ((int)arr[i].size() >= (k - sz))
          ans = max(ans, val + arr[i][k - sz - 1]);
        val += cur[i];
        val -= v[(int)arr[i].size()][idx[(int)arr[i].size()]];
      } else {
        if ((int)arr[i].size() >= (k - sz))
          ans = max(ans, val + arr[i][k - sz - 1]);
      }
    }
  }
  cout << ans << endl;
  return 0;
}
