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;
const int maxn = 3005, Log = 12, pot = (1 << Log);
int n, k;
long long dp[maxn][maxn];
int sz[maxn];
int v[maxn][maxn];
long long s[maxn];
long long sol;
int tren;
void dinamika(int x) {
  for (int i = k; i >= sz[x]; i--) {
    dp[i][tren] = max(dp[i][tren - 1], dp[i - sz[x]][tren - 1] + s[x]);
  }
  for (int i = 0; i < sz[x]; i++) {
    dp[i][tren] = dp[i][tren - 1];
  }
}
long long solve(int x) {
  long long cur = 0;
  long long sol = 0;
  for (int i = k; i >= 0; i--) {
    sol = max(sol, cur + dp[i][tren]);
    cur += v[x][k - i];
  }
  return sol;
}
vector<int> t[pot * 2];
void update(int L, int D, int x, int l, int d, int val) {
  if (L >= l && D <= d) {
    t[x].push_back(val);
    return;
  }
  if ((L + D) / 2 >= l) {
    update(L, (L + D) / 2, x * 2, l, d, val);
  }
  if ((L + D) / 2 + 1 <= d) {
    update((L + D) / 2 + 1, D, x * 2 + 1, l, d, val);
  }
}
void rijesi(int x) {
  for (int i = 0; i < (int)t[x].size(); i++) {
    tren++;
    dinamika(t[x][i]);
  }
  if (x < pot) {
    rijesi(x * 2);
    rijesi(x * 2 + 1);
  } else {
    if (x - pot < n) {
      sol = max(sol, solve(x - pot));
    }
  }
  tren -= t[x].size();
}
int main() {
  scanf("%d%d", &n, &k);
  int a;
  long long uk;
  for (int i = 0; i < n; i++) {
    scanf("%d", &sz[i]);
    uk = 0;
    for (int j = 0; j < sz[i]; j++) {
      scanf("%d", &a);
      if (j < k) {
        uk += a;
        v[i][j] = a;
      }
    }
    s[i] = uk;
    sz[i] = min(sz[i], k);
  }
  for (int i = 0; i < n; i++) {
    if (i) {
      update(0, pot - 1, 1, 0, i - 1, i);
    }
    if (i < n - 1) {
      update(0, pot - 1, 1, i + 1, n - 1, i);
    }
  }
  tren = 0;
  rijesi(1);
  printf("%lld\n", sol);
  return 0;
}
