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;
struct Update {
  int type, c;
  long long h;
};
const int N = 3005;
long long dp[N][N];
struct Knapsack {
  int cur = 0;
  Knapsack() {
    cur = 0;
    memset(dp[0], 0, sizeof dp[0]);
  }
  void addUpdate(Update u) {
    for (int i = 0; i < u.c; i++) dp[cur + 1][i] = dp[cur][i];
    for (int i = u.c; i < N; i++)
      dp[cur + 1][i] = max(dp[cur][i], dp[cur][i - u.c] + u.h);
    cur++;
  }
  void undoLastUpdate() { cur--; }
  long long bestProfitWith(int budget) { return dp[cur][budget]; }
};
struct QueueUndoTrick {
  vector<Update> updates;
  Knapsack knapsack;
  int cnt0 = 0;
  QueueUndoTrick() {}
  void pushUpdate(const Update &up) {
    knapsack.addUpdate(up);
    updates.push_back(up);
    if (up.type == 0) cnt0++;
  }
  void popUpdate() {
    if (updates.back().type == 0) cnt0--;
    updates.pop_back();
    knapsack.undoLastUpdate();
  }
  void update(int c, long long h) { pushUpdate({1, c, h}); }
  long long query(int x) { return knapsack.bestProfitWith(x); }
  void undoFront() {
    if (cnt0 == 0) {
      vector<Update> temp;
      for (Update &up : updates) temp.push_back(up), popUpdate();
      reverse(temp.begin(), temp.end());
      for (Update &up : temp) up.type = 0, pushUpdate(up);
    }
    if (updates.back().type == 1) {
      vector<Update> temp[2];
      do {
        temp[updates.back().type].push_back(updates.back());
        popUpdate();
      } while (cnt0 > 0 && temp[0].size() != temp[1].size());
      reverse(temp[0].begin(), temp[0].end());
      reverse(temp[1].begin(), temp[1].end());
      for (Update up : temp[1]) pushUpdate(up);
      for (Update up : temp[0]) pushUpdate(up);
    }
    assert(updates.back().type == 0);
    popUpdate();
  }
};
vector<int> a[N];
long long sum[N];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  QueueUndoTrick solver;
  for (int i = 1; i <= n; i++) {
    int k;
    cin >> k;
    a[i].resize(k);
    for (int j = 0; j < k; j++) {
      cin >> a[i][j];
      sum[i] += a[i][j];
    }
    solver.update(a[i].size(), sum[i]);
  }
  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    solver.undoFront();
    ans = max(ans, solver.query(k));
    long long cur = 0;
    for (int j = 1; j <= k && j <= a[i].size(); j++) {
      cur += a[i][j - 1];
      ans = max(solver.query(k - j) + cur, ans);
    }
    solver.update(a[i].size(), sum[i]);
  }
  cout << ans << endl;
}
