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 read() {
  int x = 0, f = 1;
  char c = getchar();
  while (c != '-' && c < 48) c = getchar();
  if (c == '-') f = -1, c = getchar();
  while (c > 47) x = x * 10 + (c ^ 48), c = getchar();
  return f * x;
}
const int maxn = 3e3 + 7;
const int inf = 0x3f3f3f3f;
const int mod = 1e9 + 7;
int t[maxn];
inline void Max(long long &x, long long y) {
  if (x < y) x = y;
}
int main() {
  int n = read(), k = read();
  vector<vector<long long>> a(n + 1, vector<long long>(k + 1, 0));
  for (int i = 1; i <= n; ++i) {
    int t = read();
    ::t[i] = t;
    for (int j = 1; j <= t; ++j) {
      int d = read();
      if (j <= k) a[i][j] = a[i][j - 1] + d;
    }
  }
  long long ans = 0;
  function<void(int, int, vector<long long> &)> solve =
      [&](int l, int r, vector<long long> &dp) {
        if (l == r) {
          for (int i = 0, up = min(k, t[l]); i <= up; ++i) {
            Max(ans, dp[k - i] + a[l][i]);
          }
          return;
        }
        int m = (l + r) / 2;
        vector<long long> dp1(dp);
        for (int i = m + 1; i <= r; ++i) {
          for (int j = k; j >= t[i]; --j) {
            Max(dp1[j], dp1[j - t[i]] + a[i][t[i]]);
          }
        }
        solve(l, m, dp1);
        for (int i = l; i <= m; ++i) {
          for (int j = k; j >= t[i]; --j) {
            Max(dp[j], dp[j - t[i]] + a[i][t[i]]);
          }
        }
        solve(m + 1, r, dp);
      };
  vector<long long> dp(k + 1, -1e18);
  dp[0] = 0;
  solve(1, n, dp);
  cout << ans << endl;
}
