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;
using ll = long long;
using ld = long double;
using pr = pair<int, int>;
template <typename T>
inline void _read(T arr, long long n) {
  for (long long i = 0; i < n; i++) cin >> arr[i];
}
template <typename T>
inline void _write(T arr, long long n, bool _space = true, bool _endl = true) {
  if (_space)
    for (long long i = 0; i < n; i++) cout << arr[i] << " ";
  else
    for (long long i = 0; i < n; i++) cout << arr[i];
  if (_endl) cout << endl;
}
const long long MAXN = 3033;
long long n, k;
vector<long long> arr[MAXN];
ll sum[MAXN];
ll ans = 0;
ll dp[20][MAXN];
void dfs(long long l, long long r, long long dep) {
  if (l > r) return;
  if (l == r) {
    ans = max(ans, dp[dep - 1][k]);
    ll c = 0;
    for (long long i = 0; i < k && i < arr[l].size(); i++) {
      c += arr[l][i];
      ans = max(ans, dp[dep - 1][k - i - 1] + c);
    }
    return;
  }
  if (dep) {
    memcpy(dp[dep], dp[dep - 1], sizeof(dp[dep]));
  }
  long long mid = (l + r) / 2;
  for (long long i = l; i <= mid; i++) {
    for (long long j = k - arr[i].size(); j >= 0; j--) {
      dp[dep][j + arr[i].size()] =
          max(dp[dep][j + arr[i].size()], dp[dep][j] + sum[i]);
    }
  }
  dfs(mid + 1, r, dep + 1);
  if (dep) {
    memcpy(dp[dep], dp[dep - 1], sizeof(dp[dep]));
  }
  for (long long i = mid + 1; i <= r; i++) {
    for (long long j = k - arr[i].size(); j >= 0; j--) {
      dp[dep][j + arr[i].size()] =
          max(dp[dep][j + arr[i].size()], dp[dep][j] + sum[i]);
    }
  }
  dfs(l, mid, dep + 1);
}
void __Main__() {
  cin >> n >> k;
  for (long long i = 1; i <= n; i++) {
    long long t;
    cin >> t;
    while (t--) {
      long long x;
      cin >> x;
      arr[i].push_back(x);
      sum[i] += x;
    }
  }
  dfs(1, n, 1);
  cout << ans << endl;
}
signed main() {
  ios ::sync_with_stdio(false);
  cin.tie(nullptr);
  __Main__();
  return 0;
}
