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 iinf = 1e9 + 10;
const long long inf = 1ll << 60;
const long long mod = 1e9 + 7;
void GG() {
  cout << "0\n";
  exit(0);
}
long long mpow(long long a, long long n, long long mo = mod) {
  long long re = 1;
  while (n > 0) {
    if (n & 1) re = re * a % mo;
    a = a * a % mo;
    n >>= 1;
  }
  return re;
}
long long inv(long long b, long long mo = mod) {
  if (b == 1) return b;
  return (mo - mo / b) * inv(mo % b, mo) % mo;
}
const int maxn = 3e3 + 5;
vector<int> a[maxn];
long long w[maxn], v[maxn];
int n, k;
long long re = 0;
void dfs(int l, int r, vector<long long> bk) {
  if (l == r) {
    long long vs = 0;
    for (int i = 1; i < k; ++i) {
      bk[i] = max(bk[i], bk[i - 1]);
    }
    for (long long i = 0; i < min(k, (int)a[l].size()); ++i) {
      vs += a[l][i];
      re = max(re, vs + bk[k - i - 1]);
      ;
    }
    return;
  }
  vector<long long> npk = bk;
  long long mid = (l + r) / 2;
  for (int i = l; i <= mid; ++i) {
    for (int j = k - 1; j >= 0; --j) {
      if (j - w[i] < 0) break;
      npk[j] = max(npk[j], npk[j - w[i]] + v[i]);
    }
  }
  dfs(mid + 1, r, npk);
  npk = bk;
  for (int i = mid + 1; i <= r; ++i) {
    for (int j = k - 1; j >= 0; --j) {
      if (j - w[i] < 0) break;
      npk[j] = max(npk[j], npk[j - w[i]] + v[i]);
    }
  }
  dfs(l, mid, npk);
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  ;
  cin >> n >> k;
  for (int i = 0; i < n; ++i) {
    int t;
    cin >> t;
    w[i] = t;
    for (int j = 0; j < t; ++j) {
      int x;
      cin >> x;
      a[i].push_back(x);
      v[i] += x;
    }
  }
  vector<long long> tmp(k, 0);
  dfs(0, n - 1, tmp);
  cout << re << '\n';
}
