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;
template <typename T1, typename T2>
istream& operator>>(istream& in, pair<T1, T2>& a) {
  in >> a.first >> a.second;
  return in;
}
template <typename T1, typename T2>
ostream& operator<<(ostream& out, pair<T1, T2> a) {
  out << a.first << " " << a.second;
  return out;
}
template <typename T, typename T1>
T maxs(T& a, T1 b) {
  if (b > a) a = b;
  return a;
}
template <typename T, typename T1>
T mins(T& a, T1 b) {
  if (b < a) a = b;
  return a;
}
const long long N = 3e3 + 5;
vector<pair<long long, long long> > t[4 * N];
long long n, k;
vector<long long> a[N];
long long ans = 0;
void add_item(long long l, long long r, pair<long long, long long> item,
              long long tl = 1, long long tr = n, long long v = 1) {
  if (l > tr || tl > r) return;
  if (l <= tl && tr <= r) {
    t[v].push_back(item);
    return;
  }
  long long mid = (tl + tr) / 2;
  add_item(l, r, item, tl, mid, 2 * v);
  add_item(l, r, item, mid + 1, tr, 2 * v + 1);
}
void dfs(vector<long long> dp, long long tl = 1, long long tr = n,
         long long v = 1) {
  vector<long long> new_dp = dp;
  for (auto [value, weight] : t[v]) {
    for (long long j = k; j >= weight; j--) {
      maxs(new_dp[j], new_dp[j - weight] + value);
    }
  }
  if (tl == tr) {
    for (long long i = 0; i < (long long)a[tl].size(); i++) {
      if (i > k) break;
      maxs(ans, new_dp[k - i] + a[tl][i]);
    }
    return;
  } else {
    long long mid = (tl + tr) / 2;
    dfs(new_dp, tl, mid, 2 * v);
    dfs(new_dp, mid + 1, tr, 2 * v + 1);
  }
}
long long solve() {
  cin >> n >> k;
  for (long long i = 1; i < n + 1; i++) {
    long long t;
    cin >> t;
    a[i].resize(t + 1);
    for (long long j = 1; j < t + 1; j++) {
      cin >> a[i][j];
      a[i][j] += a[i][j - 1];
    }
    if (i - 1 > 0) add_item(1, i - 1, {a[i][t], t});
    if (i + 1 <= n) add_item(i + 1, n, {a[i][t], t});
  }
  vector<long long> dp(k + 1, 0);
  dfs(dp);
  cout << ans << "\n";
  return 0;
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
