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>
char buf[1 << 21], *p1, *p2;
template <typename T>
inline void read(T& x) {
  x = 0;
  int ch =
      ((p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1 << 21, stdin), p1 == p2))
           ? EOF
           : *p1++);
  while (ch < 48 || ch > 57)
    ch = ((p1 == p2 &&
           (p2 = (p1 = buf) + fread(buf, 1, 1 << 21, stdin), p1 == p2))
              ? EOF
              : *p1++);
  while (ch > 47 && ch < 58)
    x = 10 * x + ch - 48,
    ch = ((p1 == p2 &&
           (p2 = (p1 = buf) + fread(buf, 1, 1 << 21, stdin), p1 == p2))
              ? EOF
              : *p1++);
}
int n, k;
std::vector<int> a[3123];
long long ans, s[3123];
inline void Solve(std::vector<long long>& p, int L, int R) {
  if (L == R) {
    long long tmp = 0;
    for (int i = 0; i <= static_cast<int>(a[L].size()); ++i) {
      if (i) tmp += a[L][i - 1];
      ans = std::max(ans, p[k - i] + tmp);
    }
    return;
  }
  int Mid = ((L + R) >> 1);
  std::vector<long long> l(p), r(p);
  for (int i = Mid + 1; i <= R; ++i)
    for (int j = k; j >= static_cast<int>(a[i].size()); --j)
      l[j] = std::max(l[j], s[i] + l[j - static_cast<int>(a[i].size())]);
  for (int i = L; i <= Mid; ++i)
    for (int j = k; j >= static_cast<int>(a[i].size()); --j)
      r[j] = std::max(r[j], s[i] + r[j - static_cast<int>(a[i].size())]);
  Solve(l, L, Mid);
  Solve(r, Mid + 1, R);
}
int main() {
  read(n);
  read(k);
  for (int i = 1, t; i <= n; ++i) {
    read(t);
    for (int j = 1, x; j <= t; ++j) {
      read(x);
      a[i].push_back(x);
      if (j <= k) s[i] += x;
    }
    if (static_cast<int>(a[i].size()) > k) a[i].resize(k);
  }
  std::vector<long long> tmp(k + 5, 0);
  Solve(tmp, 1, n);
  printf("%lld\n", ans);
  return 0;
}
