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;
mt19937 Rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
template <typename T>
void chkmax(T& x, T y) {
  if (x < y) x = y;
}
template <typename T>
void chkmin(T& x, T y) {
  if (x > y) x = y;
}
inline int read() {
  int x = 0;
  char c = getchar();
  bool f = 0;
  while (c < 48) f |= c == '-', c = getchar();
  while (c > 47) x = x * 10 + (c ^ 48), c = getchar();
  return f ? -x : x;
}
const int maxn = 3010;
int n, k;
long long su[maxn];
vector<int> A[maxn];
long long ans, dp[maxn], pst[15][maxn];
void divide(int l, int r, int lev) {
  if (l == r) {
    long long cur = 0;
    chkmax(ans, dp[k]);
    for (int i = (0), iend = (A[l].size() - 1); i <= iend; ++i) {
      cur += A[l][i];
      chkmax(ans, dp[k - i - 1] + cur);
    }
    return;
  }
  int mid = (l + r) / 2;
  memcpy(pst[lev], dp, sizeof dp);
  for (int i = (mid + 1), iend = (r); i <= iend; ++i)
    for (int j = (k), jend = (A[i].size()); j >= jend; --j) {
      chkmax(dp[j], dp[j - A[i].size()] + su[i]);
    }
  divide(l, mid, lev + 1);
  memcpy(dp, pst[lev], sizeof dp);
  for (int i = (l), iend = (mid); i <= iend; ++i)
    for (int j = (k), jend = (A[i].size()); j >= jend; --j) {
      chkmax(dp[j], dp[j - A[i].size()] + su[i]);
    }
  divide(mid + 1, r, lev + 1);
  memcpy(dp, pst[lev], sizeof dp);
}
void solve() {
  cin >> n >> k;
  for (int i = (1), iend = (n); i <= iend; ++i) {
    int x = read();
    vector<int> vec;
    while (x--) vec.push_back(read());
    for (int t : vec)
      if ((int)A[i].size() < k) A[i].push_back(t), su[i] += t;
  }
  divide(1, n, 0);
  cout << ans << endl;
}
signed main() {
  solve();
  return 0;
}
