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 double eps = 1e-7;
long long read() {
  long long x = 0, f = 1;
  char ch = getchar();
  for (; ch < '0' || ch > '9'; ch = getchar())
    if (ch == '-') f = -1;
  for (; ch >= '0' && ch <= '9'; ch = getchar()) x = x * 10 + ch - '0';
  return x * f;
}
void write(long long x) {
  if (x < 0)
    putchar('-'), write(-x);
  else {
    if (x >= 10) write(x / 10);
    putchar(x % 10 + '0');
  }
}
const long long MAXN = 3010;
long long n, m;
vector<long long> a[MAXN], sum[MAXN];
long long V[MAXN], W[MAXN];
long long now[MAXN];
long long Ans;
inline void dp(int l, int r) {
  if (l == r) {
    for (int i = 0; i < a[l].size() && m - i - 1 >= 0; ++i)
      Ans = max(Ans, now[m - i - 1] + sum[l][i]);
    return;
  }
  long long cur[MAXN], mid = l + r >> 1;
  for (long long i = (0); i <= (m); ++i) cur[i] = now[i];
  for (long long i = (mid + 1); i <= (r); ++i)
    for (long long j = (m); j >= (V[i]); --j)
      now[j] = max(now[j], now[j - V[i]] + W[i]);
  dp(l, mid);
  for (long long i = (0); i <= (m); ++i) now[i] = cur[i];
  for (long long i = (l); i <= (mid); ++i)
    for (long long j = (m); j >= (V[i]); --j)
      now[j] = max(now[j], now[j - V[i]] + W[i]);
  dp(mid + 1, r);
  for (long long i = (0); i <= (m); ++i) now[i] = cur[i];
}
int main() {
  Ans = (long long)-1e18;
  n = read(), m = read();
  for (long long i = (1); i <= (n); ++i) {
    long long num = read(), x, w = 0;
    V[i] = num;
    for (long long j = (1); j <= (num); ++j)
      x = read(), a[i].push_back(x), w += x;
    sum[i].push_back(a[i][0]);
    for (long long j = (1); j <= (num - 1); ++j)
      sum[i].push_back(sum[i][j - 1] + a[i][j]);
    W[i] = w;
  }
  dp(1, n);
  printf("%lld\n", Ans);
  return 0;
}
