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 n, k;
vector<int> obs[3006];
long long v[3006], w[3006];
vector<long long> dp;
long long ans = 0;
void dq(int l, int r) {
  if (l == r) {
    int t = 0;
    long long r = 0;
    for (int x : obs[l]) {
      ++t;
      r += x;
      ans = max(ans, dp[k - t] + r);
      if (t >= k) break;
    }
    return;
  }
  vector<long long> tmp = dp;
  int mid = l + r >> 1;
  for (int i = (l), iend = (mid); i <= iend; ++i) {
    for (int j = k; j >= v[i]; --j) dp[j] = max(dp[j], dp[j - v[i]] + w[i]);
  }
  dq(mid + 1, r);
  dp = tmp;
  for (int i = (mid + 1), iend = (r); i <= iend; ++i) {
    for (int j = k; j >= v[i]; --j) dp[j] = max(dp[j], dp[j - v[i]] + w[i]);
  }
  dq(l, mid);
}
void solve() {
  cin >> n >> k;
  for (int i = (1), iend = (n); i <= iend; ++i) {
    static int t;
    scanf("%d", &t);
    obs[i].resize(t);
    for (int j = (0), jend = (t - 1); j <= jend; ++j)
      scanf("%d", &obs[i][j]), w[i] += obs[i][j];
    v[i] = t;
  }
  dp.resize(k + 1);
  dq(1, n);
  cout << ans << endl;
}
signed main() { solve(); }
