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;
inline int readint() {
  int a = 0;
  char c = getchar(), f = 1;
  for (; c < '0' || c > '9'; c = getchar())
    if (c == '-') f = -f;
  for (; '0' <= c && c <= '9'; c = getchar())
    a = (a << 3) + (a << 1) + (c ^ 48);
  return a * f;
}
const int MaxN = 3005;
vector<long long> v[MaxN];
int k;
long long dp[MaxN], tmp[13][MaxN], ans;
int zxy;
void addItem(int id) {
  int t = v[id].size();
  for (int i = k; i >= t; --i) dp[i] = max(dp[i], dp[i - t] + v[id].back());
}
void solve(int l, int r, int d = 0) {
  if (l == r) {
    int len = v[l].size();
    if (len > k) len = k;
    for (int i = 0; i < len; ++i) ans = max(ans, v[l][i] + dp[k - i - 1]);
    return;
  }
  for (int i = 0; i <= k; ++i) tmp[d][i] = dp[i];
  int m = (l + r) >> 1;
  for (int i = m + 1; i <= r; ++i) addItem(i);
  solve(l, m, d + 1);
  for (int i = 0; i <= k; ++i) dp[i] = tmp[d][i];
  for (int i = l; i <= m; ++i) addItem(i);
  solve(m + 1, r, d + 1);
}
int main() {
  int n = readint();
  k = readint();
  for (int i = 1; i <= n; ++i) {
    int t = readint();
    v[i].clear();
    for (int j = 0; j < t; ++j) {
      long long x = readint();
      if (j) x += v[i].back();
      v[i].push_back(x);
    }
  }
  solve(1, n);
  printf("%lld\n", ans);
  return 0;
}
