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;
int k;
long long maxans = 0;
vector<vector<int>> allv;
vector<long long> sum;
void solve(vector<long long> &dp, int l, int r) {
  if (l == r) {
    long long a = 0;
    for (int i = 0; i <= min((int)allv[l].size(), k); i++) {
      maxans = max(maxans, dp[k - i] + a);
      if (i < min((int)allv[l].size(), k)) a += allv[l][i];
    }
    return;
  }
  vector<long long> dp2 = dp;
  int m = (l + r) / 2;
  int l1 = l, r1 = m, l2 = m + 1, r2 = r;
  for (int i = l1; i <= r1; i++) {
    for (int j = k; j >= allv[i].size(); j--)
      dp2[j] = max(dp2[j], dp2[j - allv[i].size()] + sum[i]);
  }
  vector<long long> dp1 = dp;
  solve(dp2, l2, r2);
  vector<long long>().swap(dp2);
  for (int i = l2; i <= r2; i++) {
    for (int j = k; j >= allv[i].size(); j--)
      dp1[j] = max(dp1[j], dp1[j - allv[i].size()] + sum[i]);
  }
  solve(dp1, l1, r1);
  vector<long long>().swap(dp1);
}
signed main() {
  cin.tie(NULL);
  ios_base::sync_with_stdio(false);
  int n;
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    int t;
    long long s = 0;
    cin >> t;
    allv.push_back(vector<int>(t));
    for (int j = 0; j < t; j++) cin >> allv[i][j], s += allv[i][j];
    sum.push_back(s);
  }
  vector<long long> dp(k + 1);
  solve(dp, 0, n - 1);
  cout << maxans << endl;
}
