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-8;
const int mod = 1e9 + 7;
inline int sign(double x) { return (x > eps) - (x < -eps); }
inline int add(int a, int b) {
  a += b;
  return a < 0 ? a + mod : a >= mod ? a - mod : a;
}
inline int mul(long long a, long long b) { return a * b % mod; }
const int maxn = 3e3 + 10, INF = 0x3f3f3f3f;
vector<int> v[maxn];
int n, k;
long long ans, f[maxn], sum[maxn];
void sol(int l, int r) {
  if (l == r) {
    long long val = 0;
    for (int i = 0; i <= min(k, int(v[l].size())); ++i) {
      ans = max(ans, val + f[k - i]);
      val += v[l][i];
    }
    return;
  }
  long long g[maxn];
  for (int i = 1; i <= k; ++i) g[i] = f[i];
  int m = l + r >> 1;
  for (int i = l; i <= m; ++i) {
    for (int j = k; j; --j)
      if (j >= int(v[i].size()))
        f[j] = max(f[j], f[j - int(v[i].size())] + sum[i]);
  }
  sol(m + 1, r);
  for (int i = 1; i <= k; ++i) f[i] = g[i];
  for (int i = r; i > m; --i) {
    for (int j = k; j; --j)
      if (j >= int(v[i].size()))
        f[j] = max(f[j], f[j - int(v[i].size())] + sum[i]);
  }
  sol(l, m);
}
int main() {
  cin >> n >> k;
  for (int i = 1; i <= n; ++i) {
    int t;
    scanf("%d", &t);
    while (t--) {
      int x;
      scanf("%d", &x);
      v[i].push_back(x);
      sum[i] += x;
    }
  }
  sol(1, n);
  cout << ans;
  return 0;
}
