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;
const long long inf = 1e9 + 7;
const long long max_n = 3001;
long long n, k;
vector<long long> a[max_n];
long long res = 0;
void relax(vector<long long>& dp, long long w, long long c) {
  for (long long i = k - w; i >= 0; i--) dp[i + w] = max(dp[i + w], dp[i] + c);
}
void f(long long l, long long r, vector<long long>& dp) {
  if (l == r) {
    for (long long i = 0; i <= min(k, (long long)(a[l].size()) - 1); i++) {
      res = max(res, a[l][i] + dp[k - i]);
    }
    return;
  }
  long long m = (l + r) / 2;
  vector<long long> le = dp, ri = dp;
  for (long long i = l; i <= m; i++)
    relax(le, (long long)(a[i].size()) - 1, a[i].back());
  for (long long i = m + 1; i <= r; i++)
    relax(ri, (long long)(a[i].size()) - 1, a[i].back());
  f(l, m, ri);
  f(m + 1, r, le);
}
void solve() {
  cin >> n >> k;
  for (long long i = 0; i < n; i++) {
    a[i].emplace_back(0);
    long long last = 0;
    long long t;
    cin >> t;
    while (t--) {
      long long v;
      cin >> v;
      last += v;
      a[i].emplace_back(last);
    }
  }
  vector<long long> temp(k + 1, -inf);
  temp[0] = 0;
  f(0, n - 1, temp);
  cout << res;
}
signed main() {
  cin.tie(0);
  cout.tie(0);
  ios_base::sync_with_stdio(0);
  solve();
}
