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;
template <typename T>
using minpq = priority_queue<T, vector<T>, greater<T>>;
const int N = 3005, T = 1e6 + 5;
int n, k, t[N];
vector<long long> a[N];
struct update {
  bool type;
  int idx;
  update(int idx) : idx(idx) { type = 0; }
};
struct sack {
  stack<array<long long, N>> st;
  sack() {
    array<long long, N> dp;
    fill((dp).begin(), (dp).end(), -1);
    dp[0] = 0;
    st.push(dp);
  }
  void push(const update &u) {
    int idx = u.idx;
    array<long long, N> dp;
    for (int i = (0); i < (N); i++) dp[i] = st.top()[i];
    int s = min(k, t[idx]);
    long long val = a[idx][s];
    for (int i = N - 1; i >= s; i--) {
      if (dp[i - s] != -1 && dp[i - s] + val > dp[i]) {
        dp[i] = dp[i - s] + val;
      }
    }
    st.push(dp);
  }
  long long operator[](int i) { return st.top()[i]; }
  void undo() { st.pop(); }
};
template <typename D, typename U>
struct noam : public D {
  vector<U> S;
  void push(const U &u) {
    D::push(u);
    S.push_back(u);
  }
  void pop() {
    assert(!S.empty());
    vector<U> t[2];
    do {
      t[S.back().type].push_back(S.back());
      S.pop_back();
      D::undo();
    } while (((int)(t[1]).size()) < ((int)(t[0]).size()) && !S.empty());
    if (t[1].empty()) {
      for (auto &u : t[0]) {
        u.type = 1;
        push(u);
      }
    } else
      for (int i : {0, 1}) {
        reverse((t[i]).begin(), (t[i]).end());
        for (auto &u : t[i]) push(u);
      }
    S.pop_back();
    D::undo();
  }
};
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> k;
  for (int i = (1); i < (n + 1); i++) {
    cin >> t[i];
    a[i].assign(t[i] + 1, 0);
    for (int j = (1); j < (t[i] + 1); j++) {
      cin >> a[i][j];
      a[i][j] += a[i][j - 1];
    }
  }
  long long best = -1;
  noam<sack, update> Q;
  for (int i = (1); i < (n + 1); i++) {
    Q.push(i);
  }
  for (int i = (1); i < (n + 1); i++) {
    Q.pop();
    for (int j = (0); j < (min(k, t[i]) + 1); j++) {
      long long val = Q[k - j];
      if (val != -1) {
        best = max(best, a[i][j] + val);
      }
    }
    Q.push(i);
  }
  cout << best << '\n';
}
