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;
constexpr int seed = 131;
constexpr long long LLMAX = 2e18;
constexpr int MOD = 1e9 + 7;
constexpr double eps = 1e-8;
constexpr int MAXN = 1e6 + 10;
constexpr int hmod1 = 0x48E2DCE7;
constexpr int hmod2 = 0x60000005;
inline long long sqr(long long x) { return x * x; }
inline int sqr(int x) { return x * x; }
inline double sqr(double x) { return x * x; }
inline int mul(int x, int y) { return 1ll * x * y % MOD; }
inline int sub(int x, int y) { return x >= y ? x - y : MOD + x - y; }
inline int add(int x, int y) { return x + y >= MOD ? x + y - MOD : x + y; }
inline int dcmp(double x) {
  if (fabs(x) < eps) return 0;
  return (x > 0 ? 1 : -1);
}
inline long long qpow(long long a, long long n) {
  long long sum = 1;
  while (n) {
    if (n & 1) sum = sum * a % MOD;
    a = a * a % MOD;
    n >>= 1;
  }
  return sum;
}
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
long long exgcd(long long a, long long b, long long &x, long long &y) {
  long long d;
  (b == 0 ? (x = 1, y = 0, d = a)
          : (d = exgcd(b, a % b, y, x), y -= a / b * x));
  return d;
}
int n, k, t[3010], a[3010][3010];
long long ans, sum[3010], dp[3010], tp[15][3010];
void cdq(int l, int r, int d) {
  if (l == r)
    for (long long i = 0, s = 0; i <= t[l]; i++)
      ans = max(ans, dp[k - i] + s), s += a[l][i];
  else {
    int mid = (l + r) >> 1;
    std::memcpy(tp[d], dp, (k + 1) * sizeof(long long));
    for (int i = mid + 1; i <= r; i++)
      for (int j = k; j >= t[i]; j--) dp[j] = max(dp[j], dp[j - t[i]] + sum[i]);
    cdq(l, mid, d + 1);
    std::memcpy(dp, tp[d], (k + 1) * sizeof(long long));
    for (int i = l; i <= mid; i++)
      for (int j = k; j >= t[i]; j--) dp[j] = max(dp[j], dp[j - t[i]] + sum[i]);
    cdq(mid + 1, r, d + 1);
  }
}
int main(void) {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> k;
  for (int i = 1; i <= n; i++) {
    cin >> t[i];
    for (int j = 0, x; j < t[i]; j++) {
      if (j > k)
        cin >> x;
      else
        cin >> a[i][j];
    }
    t[i] = min(t[i], k);
    for (int j = 0; j < t[i]; j++) sum[i] += a[i][j];
  }
  cdq(1, n, 0);
  cout << ans << endl;
  return 0;
}
