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>
int n, k;
std::vector<int> vec[3001];
int siz[3001];
long long v[3001];
long long f[3010][3001];
void add(long long *a, int s, long long v) {
  for (int i = k; i >= s; i--) a[i] = std::max(a[i], a[i - s] + v);
}
void solve(int l, int r) {
  if (l == r) {
    long long v = 0;
    for (int i = 0; i < vec[l].size() && i + 1 <= k; i++) {
      v += vec[l][i];
      f[l][i + 1] = v;
    }
    siz[l] = vec[l].size();
    ::v[l] = v;
    return;
  }
  int mid = (l + r) >> 1;
  solve(l, mid);
  solve(mid + 1, r);
  for (int i = mid + 1; i <= r; i++) add(f[l], siz[i], v[i]);
  for (int i = mid; i >= l; i--) add(f[mid + 1], siz[i], v[i]);
  for (int i = 0; i <= k; i++) f[l][i] = std::max(f[l][i], f[mid + 1][i]);
}
int read() {
  int x = 0;
  char ch = getchar();
  while (ch < '0' || ch > '9') ch = getchar();
  while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
  return x;
}
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n; i++) {
    int tem;
    scanf("%d", &tem);
    vec[i].resize(tem);
    for (int j = 0; j < tem; j++) vec[i][j] = read();
  }
  solve(1, n);
  printf("%lld\n", f[1][k]);
}
