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 LL = long long;
using pii = std::pair<int, int>;
using pll = std::pair<LL, LL>;
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  int n, k;
  std::cin >> n >> k;
  std::vector<std::vector<LL>> a(n);
  for (auto &p : a) {
    int cnt;
    std::cin >> cnt;
    p.emplace_back(0);
    for (int i = 0, x; i < cnt; ++i) {
      std::cin >> x;
      if (i < k) p.push_back(p.back() + x);
    }
  }
  std::vector<LL> dp(k + 1, -1e18);
  dp[0] = 0;
  auto merge = [&](int l, int r) {
    for (int i = l; i < r; ++i) {
      for (int j = k; j >= a[i].size() - 1; --j) {
        dp[j] = std::max(dp[j], dp[j - a[i].size() + 1] + a[i].back());
      }
    }
  };
  LL ans = 0;
  std::function<void(int, int)> divide = [&](int l, int r) {
    if (l + 1 >= r) {
      for (int i = 0; i < a[l].size(); ++i)
        ans = std::max(ans, dp[k - i] + a[l][i]);
      return;
    }
    int m = (l + r + 1) / 2;
    auto tmp = dp;
    merge(l, m);
    divide(m, r);
    dp = tmp;
    merge(m, r);
    divide(l, m);
  };
  divide(0, n);
  std::cout << ans << std::endl;
  return 0;
}
