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 int N = 3000 + 7;
int n;
int k;
vector<long long> a[N];
int len[N];
long long full[N];
long long sol = 0;
vector<long long> dp;
vector<vector<long long>> memory;
void upd(int len, long long val) {
  memory.push_back(dp);
  for (int t = k - len; t >= 0; t--) {
    dp[t + len] = max(dp[t + len], dp[t] + val);
  }
}
void undo() {
  dp = memory.back();
  memory.pop_back();
}
void run(int l, int r) {
  if (l == r) {
    for (int t = 0; t <= k; t++) {
      int rem = min(k - t, (int)a[l].size());
      if (rem > 0) {
        sol = max(sol, dp[t] + a[l][rem - 1]);
      }
    }
  } else {
    int m = (l + r) / 2;
    for (int j = m + 1; j <= r; j++) {
      upd(len[j], full[j]);
    }
    run(l, m);
    for (int j = m + 1; j <= r; j++) {
      undo();
    }
    for (int j = l; j <= m; j++) {
      upd(len[j], full[j]);
    }
    run(m + 1, r);
    for (int j = l; j <= m; j++) {
      undo();
    }
  }
}
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> k;
  dp.resize(k + 1, 0);
  dp[0] = 0;
  for (int i = 1; i <= n; i++) {
    cin >> len[i];
    a[i].resize(len[i]);
    for (int j = 0; j < len[i]; j++) {
      cin >> a[i][j];
      full[i] += a[i][j];
      a[i][j] = full[i];
    }
  }
  run(1, n);
  cout << sol << "\n";
}
