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;
template <typename T1, typename T2>
inline void chkmin(T1 &a, T2 b) {
  if (a > b) a = b;
}
template <typename T1, typename T2>
inline void chkmax(T1 &a, T2 b) {
  if (a < b) a = b;
}
using ll = long long;
using ld = long double;
const string FILENAME = "input";
const int MAXN = 1000228;
int n, k;
vector<ll> have[MAXN];
ll sum[MAXN];
ll ans;
ll dp[3050][3050];
void add(int v, int uk) {
  for (int i = 0; i <= k; i++) {
    dp[uk + 1][i] = dp[uk][i];
  }
  int r = (int)(have[v]).size();
  for (int i = 0; i <= k - r; i++) {
    chkmax(dp[uk + 1][i + r], dp[uk][i] + sum[v]);
  }
}
void calc(int a, int b, int g) {
  if (a == b) {
    ll suma = 0;
    for (int i = 0; i <= (int)(have[a]).size() && i <= k; i++) {
      chkmax(ans, suma + dp[g][k - i]);
      if (i < (int)(have[a]).size()) {
        suma += have[a][i];
      }
    }
    return;
  }
  int s = (a + b) >> 1;
  {
    int p = g;
    for (int i = a; i <= s; i++) {
      add(i, p);
      p++;
    }
    calc(s + 1, b, p);
  }
  {
    int p = g;
    for (int i = s + 1; i <= b; i++) {
      add(i, p);
      p++;
    }
    calc(a, s, p);
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> k;
  for (int i = 1; i <= n; i++) {
    int m;
    cin >> m;
    for (int j = 0; j < m; j++) {
      int w;
      cin >> w;
      have[i].push_back(w);
      sum[i] += w;
    }
  }
  calc(1, n, 0);
  cout << ans << '\n';
  return 0;
}
