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;
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx,avx2,sse,sse2,sse3,sse4,tune=native")
vector<vector<long long>> a;
vector<long long> s;
long long ans = 0;
vector<long long> dp;
long long k;
inline void solve(long long l, long long r) {
  assert(l < r);
  if (l + 1 == r) {
    vector<long long> ps = dp;
    for (long long j = 1; j <= k; ++j) {
      dp[j] = max(dp[j], dp[j - 1]);
    }
    long long sum = 0;
    for (long long j = 0; j < a[l].size(); ++j) {
      sum += a[l][j];
      if (k - j - 1 >= 0) {
        ans = max(ans, sum + dp[k - j - 1]);
      } else {
        break;
      }
    }
    dp = ps;
    return;
  }
  long long m = (l + r) / 2;
  vector<long long> ps = dp;
  for (long long i = m; i < r; ++i) {
    for (long long j = k; j >= a[i].size(); --j) {
      dp[j] = max(dp[j], dp[j - a[i].size()] + s[i]);
    }
  }
  solve(l, m);
  dp = ps;
  for (long long i = l; i < m; ++i) {
    for (long long j = k; j >= a[i].size(); --j) {
      dp[j] = max(dp[j], dp[j - a[i].size()] + s[i]);
    }
  }
  solve(m, r);
  dp = ps;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long n;
  cin >> n >> k;
  a.resize(n);
  s.assign(n, 0);
  dp.assign(k + 1, 0);
  for (long long i = 0; i < n; ++i) {
    long long t;
    cin >> t;
    a[i].resize(t);
    for (long long j = 0; j < t; ++j) {
      cin >> a[i][j];
      s[i] += a[i][j];
    }
  }
  solve(0, n);
  cout << ans;
}
