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>
int min(int a, int b) { return a < b ? a : b; }
long long max(long long a, long long b) { return a > b ? a : b; }
long long aa[3000][3000 + 1], dp[3000][3000 + 1];
int kk[3000];
int k_;
void solve(int l, int r) {
  if (r - l > 1) {
    int m, i, k;
    m = (l + r) / 2;
    memcpy(dp[m], dp[l], (k_ + 1) * sizeof *dp[l]);
    for (i = l; i < m; i++)
      for (k = k_; k >= kk[i]; k--)
        if (dp[m][k - kk[i]] != -1)
          dp[m][k] = max(dp[m][k], dp[m][k - kk[i]] + aa[i][kk[i]]);
    for (i = m; i < r; i++)
      for (k = k_; k >= kk[i]; k--)
        if (dp[l][k - kk[i]] != -1)
          dp[l][k] = max(dp[l][k], dp[l][k - kk[i]] + aa[i][kk[i]]);
    solve(l, m);
    solve(m, r);
  }
}
int main() {
  int n, i, k;
  long long ans;
  scanf("%d%d", &n, &k_);
  for (i = 0; i < n; i++) {
    scanf("%d", &kk[i]);
    for (k = 1; k <= kk[i]; k++) {
      int a;
      scanf("%d", &a);
      if (k <= k_) aa[i][k] = aa[i][k - 1] + a;
    }
    kk[i] = min(kk[i], k_);
  }
  for (i = 0; i < n; i++)
    memset(dp[i], -1, (k_ + 1) * sizeof *dp[i]), dp[i][0] = 0;
  solve(0, n);
  ans = 0;
  for (i = 0; i < n; i++)
    for (k = 0; k <= kk[i]; k++)
      if (dp[i][k_ - k] != -1) ans = max(ans, dp[i][k_ - k] + aa[i][k]);
  printf("%lld\n", ans);
  return 0;
}
