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 INF = 1LL << 61;
int size1[3005];
vector<int> A[3005];
vector<long long> prefixSum[3005];
int W[3005];
long long V[3005];
long long dp[3005][3005];
int indx[3005];
long long temp[3005];
long long ans = 0;
int n, k;
void relax(int i) {
  for (int j = 0; j <= k; j++) {
    temp[j] = dp[j][indx[j]];
    indx[j]++;
  }
  for (int j = 0; j <= k; j++) {
    long long temp2 = temp[j];
    if (j >= W[i]) {
      temp2 = max(V[i] + temp[j - W[i]], temp[j]);
    }
    dp[j][indx[j]] = temp2;
  }
}
void rollback(int x = 1) {
  for (int j = 0; j <= k; j++) {
    indx[j] -= x;
  }
}
void dnc(int s = 0, int e = n - 1) {
  if (s == e) {
    long long temp = -INF;
    for (int j = 0; j <= min(k, size1[s]); j++) {
      temp = max(temp, dp[k - j][indx[k - j]] + prefixSum[s][j]);
    }
    ans = max(ans, temp);
    return;
  }
  int m = (s + e) >> 1;
  for (int i = m + 1; i <= e; i++) {
    relax(i);
  }
  dnc(s, m);
  for (int i = m + 1; i <= e; i++) {
    rollback();
  }
  for (int i = s; i <= m; i++) {
    relax(i);
  }
  dnc(m + 1, e);
  for (int i = s; i <= m; i++) {
    rollback();
  }
}
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 0; i < n; i++) {
    scanf("%d", &size1[i]);
    long long sum = 0;
    prefixSum[i].push_back(sum);
    for (int j = 0; j < size1[i]; j++) {
      int x;
      scanf("%d", &x);
      sum += x;
      A[i].push_back(x);
      prefixSum[i].push_back(sum);
    }
    W[i] = size1[i];
    V[i] = sum;
  }
  dp[0][0] = 0;
  indx[0] = 0;
  for (int i = 1; i <= k; i++) {
    dp[i][0] = -INF;
    indx[i] = 0;
  }
  dnc();
  printf("%lld\n", ans);
  return 0;
}
