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")
using namespace std;
template <typename T1, typename T2>
inline void remax(T1& a, T2 b) {
  a = max(a, (T1)b);
}
const int maxN = 3030;
const long long INF = 1000000000000000ll;
vector<long long> T[maxN], dp[maxN];
int n, k;
long long res;
void uzyj(int j) {
  int m = ((long long)(T[j]).size()) - 1;
  for (int i = (k); i > (m - 1); i--) {
    long long cur = dp[i - m].back() + T[j][m];
    dp[i].push_back(max(dp[i].back(), cur));
  }
}
void anul(int j) {
  int m = ((long long)(T[j]).size()) - 1;
  for (int i = (m); i < (k + 1); i++) dp[i].pop_back();
}
void go(int a, int b) {
  int n = b - a, c = a + n / 2;
  if (n == 1) {
    int m = ((long long)(T[a]).size()) - 1;
    for (int i = (1); i < (min(k, m) + 1); i++)
      res = max(res, T[a][i] + dp[k - i].back());
    return;
  }
  for (int i = (a); i < (c); i++) uzyj(i);
  go(c, b);
  for (int i = (c - 1); i > (a - 1); i--) anul(i);
  for (int i = (c); i < (b); i++) uzyj(i);
  go(a, c);
  for (int i = (b - 1); i > (c - 1); i--) anul(i);
}
void solve() {
  scanf("%d%d", &n, &k);
  for (int i = (0); i < (n); i++) {
    int m;
    scanf("%d", &m);
    T[i].resize(m + 1);
    for (int j = (1); j < (m + 1); j++)
      scanf("%lld", &T[i][j]), T[i][j] += T[i][j - 1];
  }
  for (int i = (0); i < (k + 1); i++) dp[i].push_back(-INF);
  dp[0][0] = 0;
  go(0, n);
  printf("%lld\n", res);
}
int main() {
  int t = 1;
  for (int tid = (1); tid < (t + 1); tid++) {
    solve();
  }
  return 0;
}
