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>
#pragma GCC optimize("Ofast", "unroll-loops", "omit-frame-pointer", "inline")
#pragma GCC option("arch=native", "tune=native", "no-zero-upper")
#pragma GCC target("avx2")
using namespace std;
template <typename T>
void maxtt(T& t1, T t2) {
  t1 = max(t1, t2);
}
template <typename T>
void mintt(T& t1, T t2) {
  t1 = min(t1, t2);
}
bool debug = 0;
int n, m, k;
int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
string direc = "RDLU";
const long long MOD2 = (long long)998244353 * (long long)998244353;
long long ln, lk, lm;
void etp(bool f = 0) {
  puts(f ? "YES" : "NO");
  exit(0);
}
void addmod(int& x, int y, int mod = 998244353) {
  x += y;
  if (x >= mod) x -= mod;
  if (x < 0) x += mod;
  assert(x >= 0 && x < mod);
}
void et(int x = -1) {
  printf("%d\n", x);
  exit(0);
}
long long fastPow(long long x, long long y, int mod = 998244353) {
  long long ans = 1;
  while (y > 0) {
    if (y & 1) ans = (x * ans) % mod;
    x = x * x % mod;
    y >>= 1;
  }
  return ans;
}
long long gcd1(long long x, long long y) { return y ? gcd1(y, x % y) : x; }
vector<int> a[(3135)];
int le[(3135)];
long long S[(3135)], ans;
void cal(int l, int r, vector<long long>& dp) {
  if (l == r) {
    maxtt(ans, dp[k]);
    long long pre = 0;
    for (int(j) = 0; (j) < (int)(le[r]); (j)++) {
      if (k - j - 1 < 0) break;
      pre += a[r][j];
      maxtt(ans, pre + dp[k - j - 1]);
    }
    return;
  }
  vector<long long> tmp = dp;
  int mid = (l + r) / 2;
  for (int i = l; i <= mid; i++) {
    for (int j = k - le[i]; j >= 0; j--) {
      maxtt(tmp[j + le[i]], tmp[j] + S[i]);
    }
  }
  cal(mid + 1, r, tmp);
  tmp = dp;
  for (int i = mid + 1; i <= r; i++) {
    for (int j = k - le[i]; j >= 0; j--) {
      maxtt(tmp[j + le[i]], tmp[j] + S[i]);
    }
  }
  cal(l, mid, tmp);
}
void fmain(int tid) {
  scanf("%d%d", &n, &k);
  for (int(i) = 1; (i) <= (int)(n); (i)++) {
    scanf("%d", le + i);
    a[i].resize(le[i]);
    for (int(j) = 0; (j) < (int)(le[i]); (j)++) {
      scanf("%d", &a[i][j]);
      S[i] += a[i][j];
    }
  }
  vector<long long> tmp(k + 1, 0);
  cal(1, n, tmp);
  printf("%lld\n", ans);
}
int main() {
  int t = 1;
  for (int(i) = 1; (i) <= (int)(t); (i)++) {
    fmain(i);
  }
  return 0;
}
