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<vector<long long>> v;
vector<vector<long long>> prefix;
long long sum[3010];
long long ans;
void apply(int l, int r, vector<long long>& ks) {
  for (int i = l; i <= r; i++) {
    for (int j = ks.size() - 1; j >= 0; j--) {
      if (j + v[i].size() < ks.size()) {
        ks[j + v[i].size()] = max(ks[j + v[i].size()], ks[j] + sum[i]);
      }
    }
  }
}
void solve(int l, int r, vector<long long>& ks) {
  if (l == r) {
    for (int i = 0; i < ks.size(); i++) {
      long long cur = ks[i];
      int remaining = ks.size() - i - 1;
      if (remaining != 0)
        cur += prefix[l][min(int(prefix[l].size()) - 1, remaining - 1)];
      ans = max(ans, cur);
    }
    return;
  }
  int mid = (l + r) / 2;
  auto ks_copy = ks;
  apply(mid + 1, r, ks);
  solve(l, mid, ks);
  ks = ks_copy;
  apply(l, mid, ks);
  solve(mid + 1, r, ks);
  ks = ks_copy;
}
int main() {
  int n, k;
  scanf("%d %d", &n, &k);
  for (int i = 0; i < n; i++) {
    int t;
    scanf("%d", &t);
    vector<long long> aux;
    vector<long long> aux2;
    long long s = 0;
    for (int j = 0; j < t; j++) {
      long long x;
      scanf("%lld", &x);
      aux.push_back(x);
      s += x;
      aux2.push_back(s);
    }
    v.push_back(aux);
    prefix.push_back(aux2);
    sum[i] = s;
  }
  vector<long long> ks(k + 1, 0);
  solve(0, n - 1, ks);
  printf("%lld\n", ans);
  return 0;
}
