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;
long long n, k;
vector<long long> vec[3005];
long long num[3005], sum[3005];
stack<vector<long long> > stk;
long long ans = -1e18;
void calc(long long l, long long r) {
  if (l == r) {
    long long sum = 0;
    for (long long(i) = (0); (i) <= (vec[l].size()); (i)++) {
      (ans) = max((ans), (sum + stk.top()[k - i]));
      if (i < vec[l].size()) sum += vec[l][i];
    }
    return;
  }
  long long m = (l + r) / 2;
  vector<long long> tmp = stk.top();
  for (long long(i) = (l); (i) <= (m); (i)++) {
    for (int j = k; j >= 0; j--) {
      if (j - num[i] >= 0) (tmp[j]) = max((tmp[j]), (tmp[j - num[i]] + sum[i]));
    }
  }
  stk.push(tmp);
  calc(m + 1, r);
  stk.pop();
  tmp = stk.top();
  for (long long(i) = (m + 1); (i) <= (r); (i)++) {
    for (int j = k; j >= 0; j--) {
      if (j - num[i] >= 0) (tmp[j]) = max((tmp[j]), (tmp[j - num[i]] + sum[i]));
    }
  }
  stk.push(tmp);
  calc(l, m);
  stk.pop();
}
int main(void) {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> k;
  long long t, x;
  for (long long(i) = (1); (i) <= (n); (i)++) {
    cin >> t;
    for (long long(j) = (1); (j) <= (t); (j)++) {
      cin >> x;
      vec[i].push_back(x);
    }
    if (t > k) vec[i].resize(k);
    num[i] = vec[i].size();
    for (auto x : vec[i]) sum[i] += x;
  }
  stk.push(vector<long long>(k + 1));
  for (long long(i) = (1); (i) <= (k); (i)++) stk.top()[i] = -1e18;
  calc(1, n);
  cout << ans << endl;
  return 0;
}
