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>
const int md = 998244353;
const long long inf = 2e18;
const int OO = 1;
using namespace std;
struct knapsack {
  int k;
  vector<vector<long long>> st;
  vector<long long> dp;
  knapsack(int sz) {
    k = sz;
    dp.resize(k + 1, -inf);
    dp[0] = 0;
  }
  void upd(int sz, long long val) {
    st.push_back(dp);
    for (int i = k; i >= sz; i--) dp[i] = max(dp[i], dp[i - sz] + val);
  }
  void undo() {
    dp = st.back();
    st.pop_back();
  }
};
int n, k;
vector<vector<long long>> a;
long long ans = -inf;
void work(int l, int r, knapsack &dp) {
  if (l > r) return;
  if (l == r) {
    long long mx = 0;
    for (int i = 0; i < k; i++) {
      mx = max(mx, dp.dp[i]);
      if (k - i <= a[l].size()) ans = max(ans, mx + a[l][k - i - 1]);
    }
    mx = max(mx, dp.dp[k]);
    ans = max(ans, mx);
    return;
  }
  int mid = (l + r) / 2;
  for (int i = l; i <= mid; i++) dp.upd(a[i].size(), a[i].back());
  work(mid + 1, r, dp);
  for (int i = l; i <= mid; i++) dp.undo();
  for (int i = mid + 1; i <= r; i++) dp.upd(a[i].size(), a[i].back());
  work(l, mid, dp);
  for (int i = mid + 1; i <= r; i++) dp.undo();
}
void solve() {
  cin >> n >> k;
  a.resize(n);
  for (int i = 0; i < n; i++) {
    int len, what;
    cin >> len;
    a[i].resize(min(k, len));
    for (auto &j : a[i]) cin >> j;
    for (int x = min(k, len); x < len; x++) cin >> what;
    for (int j = 1; j < a[i].size(); j++) a[i][j] += a[i][j - 1];
  }
  knapsack dp(k);
  work(0, n - 1, dp);
  cout << ans << '\n';
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0);
  int tst = 1;
  while (tst--) {
    solve();
  }
}
