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;
int n, k, m, N;
vector<vector<long long> > g;
vector<long long> w, c;
long long res = 0;
void upd(long long& x, long long y) {
  if (x < y) x = y;
}
void add(vector<long long>& dp, int e) {
  if (!w[e]) return;
  for (int i = k; i >= w[e]; --i) upd(dp[i], dp[i - w[e]] + c[e]);
}
void rec(int l, int r, vector<long long> dp) {
  if (l == r) {
    for (int j = 0; j <= k && j < g[r].size(); ++j)
      upd(res, g[r][j] + dp[k - j]);
    return;
  }
  int m = (l + r) / 2;
  vector<long long> d = dp;
  for (int i = m + 1; i <= r; ++i) add(d, i);
  rec(l, m, d);
  d = dp;
  for (int i = l; i <= m; ++i) add(d, i);
  rec(m + 1, r, d);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> k;
  N = 1;
  while (N < n) N *= 2;
  w = c = vector<long long>(N, 0);
  g.resize(N);
  for (int i = 0; i < n; ++i) {
    cin >> m;
    g[i].assign(m + 1, 0);
    for (int j = 1; j <= m; ++j) {
      cin >> g[i][j];
      g[i][j] += g[i][j - 1];
    }
    w[i] = m;
    c[i] = g[i][m];
  }
  rec(0, N - 1, vector<long long>(k + 1, 0));
  cout << res << endl;
  return 0;
}
