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;
vector<long long> pref[3010];
long long rcs[23][3010], ok[23][3010];
int k;
long long solve(int st, int dr, int h) {
  int mid = (st + dr) / 2, i, j, elem;
  long long sol, sum;
  if (st == dr) {
    sol = -1;
    for (i = 0; i <= k && i <= pref[st].size(); i++) {
      if (!i && ok[h][k])
        sol = rcs[h][k];
      else if (i && k - i >= 0 && ok[h][k - i])
        sol = max(sol, rcs[h][k - i] + pref[st][i - 1]);
    }
    return sol;
  }
  for (i = 0; i <= k; i++) {
    rcs[h + 1][i] = rcs[h][i];
    ok[h + 1][i] = ok[h][i];
  }
  for (i = mid + 1; i <= dr; i++) {
    elem = pref[i].size();
    sum = pref[i].back();
    for (j = k - elem; j >= 0; j--) {
      if (ok[h + 1][j]) {
        if (!ok[h + 1][j + elem] ||
            rcs[h + 1][j + elem] < rcs[h + 1][j] + sum) {
          ok[h + 1][j + elem] = 1;
          rcs[h + 1][j + elem] = rcs[h + 1][j] + sum;
        }
      }
    }
  }
  sol = solve(st, mid, h + 1);
  for (i = 0; i <= k; i++) {
    rcs[h + 1][i] = rcs[h][i];
    ok[h + 1][i] = ok[h][i];
  }
  for (i = st; i <= mid; i++) {
    elem = pref[i].size();
    sum = pref[i].back();
    for (j = k - elem; j >= 0; j--) {
      if (ok[h + 1][j]) {
        if (!ok[h + 1][j + elem] ||
            rcs[h + 1][j + elem] < rcs[h + 1][j] + sum) {
          ok[h + 1][j + elem] = 1;
          rcs[h + 1][j + elem] = rcs[h + 1][j] + sum;
        }
      }
    }
  }
  sol = max(sol, solve(mid + 1, dr, h + 1));
  return sol;
}
int main() {
  FILE *fin = stdin;
  FILE *fout = stdout;
  int n, elem, x, i, j, aux, idx, val, poz;
  long long sum, sol, maxi;
  fscanf(fin, "%d%d", &n, &k);
  for (i = 1; i <= n; i++) {
    fscanf(fin, "%d", &elem);
    sum = 0;
    for (j = 1; j <= elem; j++) {
      fscanf(fin, "%d", &x);
      if (j <= k) {
        sum += x;
        pref[i].push_back(sum);
      }
    }
  }
  ok[0][0] = 1;
  fprintf(fout, "%lld", solve(1, n, 0));
  return 0;
}
