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", "unroll-loops", "omit-frame-pointer", "inline")
#pragma GCC option("arch=native", "tune=native", "no-zero-upper")
#pragma GCC target("avx2")
using namespace std;
const long long mod = 998244353;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
long long mul(long long a, long long b) { return ((a)*1ll * (b)) % mod; }
void add(long long& a, long long b) {
  a += b;
  if (a >= mod) a -= mod;
}
long long sub(long long a, long long b) {
  a -= b;
  if (a < 0) {
    a += mod;
  }
  return a;
}
long long powz(long long a, long long b) {
  long long res = 1;
  while (b) {
    if (b & 1) {
      res = mul(res, a);
    }
    b /= 2;
    a = mul(a, a);
  }
  return res;
}
template <typename A, typename B>
istream& operator>>(istream& input, pair<A, B>& x) {
  input >> x.first >> x.second;
  return input;
}
template <typename A>
istream& operator>>(istream& input, vector<A>& x) {
  for (auto& i : x) input >> i;
  return input;
}
template <typename A>
ostream& operator<<(ostream& output, vector<A>& x) {
  for (auto& i : x) output << i << ' ';
  return output;
}
template <typename T>
inline bool uax(T& x, T y) {
  return (y > x) ? x = y, true : false;
}
template <typename T>
inline bool uin(T& x, T y) {
  return (y < x) ? x = y, true : false;
}
template <typename T>
vector<pair<T, long long>> getvec(long long n) {
  vector<pair<T, long long>> a(n);
  for (long long i = 0; i < a.size(); i++) {
    cin >> a[i].first;
    a[i].second = i;
  }
  return a;
}
const long long N = 1000005;
long long dp[3005][3005];
long long dp2[3005][3005];
void solve() {
  long long n, k;
  cin >> n >> k;
  vector<vector<long long>> a(n);
  for (long long i = 0; i < n; i++) {
    long long t;
    cin >> t;
    a[i].resize(t);
    cin >> a[i];
  }
  for (long long i = 0; i < n; i++) {
    long long sm = 0;
    long long took = 0;
    for (long long j = 0; j < min((long long)a[i].size(), k); j++) {
      sm += a[i][j];
      took++;
    }
    for (long long val = 0; val <= k - took; val++) {
      dp[i + 1][val + took] = max(dp[i + 1][val + took], dp[i][val] + sm);
    }
    for (long long val = 0; val <= k; val++) {
      if (val) dp[i + 1][val] = max(dp[i + 1][val], dp[i + 1][val - 1]);
      dp[i + 1][val] = max(dp[i + 1][val], dp[i][val]);
    }
  }
  for (long long i = n - 1; i >= 0; i--) {
    long long sm = 0;
    long long took = 0;
    for (long long j = 0; j < min((long long)a[i].size(), k); j++) {
      sm += a[i][j];
      took++;
    }
    42;
    for (long long val = 0; val <= k - took; val++) {
      dp2[i + 1][val + took] =
          max(dp2[i + 1][val + took], dp2[i + 2][val] + sm);
    }
    for (long long val = 0; val <= k; val++) {
      if (val) dp2[i + 1][val] = max(dp2[i + 1][val], dp2[i + 1][val - 1]);
      dp2[i + 1][val] = max(dp2[i + 1][val], dp2[i + 2][val]);
    }
  }
  long long ans = 0;
  for (long long i = 0; i < n; i++) {
    long long sm = 0;
    long long took = 0;
    for (long long x = 0; x + took <= k; x++) {
      ans = max(ans, sm + dp[i][x] + dp2[i + 2][k - x - took]);
    }
    for (long long j = 0; j < a[i].size(); j++) {
      took++;
      sm += a[i][j];
      if (took > k) {
        break;
      }
      for (long long x = 0; x + took <= k; x++) {
        ans = max(ans, sm + dp[i][x] + dp2[i + 2][k - x - took]);
        if (i == 0 && took == 1 && (k - x - took == 2)) {
          42;
        }
      }
    }
  }
  cout << ans;
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long tc = 1;
  for (long long _ = 0; _ < tc; _++) {
    solve();
    if (_ != tc - 1) {
      cout << '\n';
    }
  }
}
