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;
ostream& operator<<(ostream& out, const vector<long long>& b) {
  for (auto k : b) out << k << " ";
  return out;
}
istream& operator>>(istream& in, pair<long long, long long>& b) {
  in >> b.first >> b.second;
  return in;
}
ostream& operator<<(ostream& out, const pair<long long, long long>& b) {
  out << "{" << b.first << ", " << b.second << "}";
  return out;
}
template <typename T1, typename T2>
inline bool chkmin(T1& x, const T2& y) {
  if (x > y) {
    x = y;
    return 1;
  }
  return 0;
}
template <typename T1, typename T2>
inline bool chkmax(T1& x, const T2& y) {
  if (x < y) {
    x = y;
    return 1;
  }
  return 0;
}
const long double PI = 4 * atan(1);
mt19937 gen(chrono::high_resolution_clock::now().time_since_epoch().count());
const long long MAXN = 3010;
long long n, k;
long long sz[MAXN];
vector<long long> a[MAXN], pref[MAXN];
long long ans = 0;
void relax(vector<long long>& dp, long long l, long long r) {
  for (long long i = l; i < r; i++) {
    for (long long j = k - sz[i]; j >= 0; j--) {
      chkmax(dp[j + sz[i]], dp[j] + pref[i][sz[i] - 1]);
    }
  }
}
void solve(long long l, long long r, vector<long long> dp) {
  if (l + 1 == r) {
    chkmax(ans, dp[k]);
    for (long long i = 0; i < k; i++) {
      chkmax(ans, dp[i] + pref[l][min(k - i - 1, sz[l] - 1)]);
    }
    return;
  }
  long long m = (l + r) / 2;
  vector<long long> dp1 = dp;
  relax(dp1, m, r);
  solve(l, m, dp1);
  dp1 = dp;
  relax(dp1, l, m);
  solve(m, r, dp1);
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> k;
  for (long long i = 0; i < n; i++) {
    cin >> sz[i];
    a[i].resize(sz[i]);
    pref[i].resize(sz[i]);
    for (long long j = 0; j < sz[i]; j++) {
      cin >> a[i][j];
      pref[i][j] = (j > 0 ? pref[i][j - 1] : 0) + a[i][j];
    }
  }
  vector<long long> dp(k + 1, 0);
  solve(0, n, dp);
  cout << ans << "\n";
}
