#include <bits/stdc++.h>
#pragma GCC optimize(2)
using namespace std;
const int INF = 0x3f3f3f3f;
const int MAXN = 3e3 + 20;
vector<long long> a[MAXN];
int t[MAXN];
long long sum[MAXN];
int n, k;
vector<long long> dfs(int l, int r) {
  vector<long long> v(k + 1, 0);
  if (l > r) return v;
  if (l == r) {
    return a[l];
  }
  vector<long long> L, R;
  int mid = (l + r) >> 1;
  L = dfs(l, mid);
  for (int i = mid + 1; i <= r; ++i) {
    for (int j = k; j >= t[i]; --j) L[j] = max(L[j], L[j - t[i]] + sum[i]);
  }
  R = dfs(mid + 1, r);
  for (int i = l; i <= mid; ++i) {
    for (int j = k; j >= t[i]; --j) R[j] = max(R[j], R[j - t[i]] + sum[i]);
  }
  for (int i = 0; i <= k; ++i) v[i] = max(L[i], R[i]);
  return v;
}
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n; ++i) {
    int ti;
    scanf("%d", &ti);
    a[i].push_back(0);
    for (int j = 1; j <= ti; ++j) {
      int ai;
      scanf("%d", &ai);
      a[i].push_back(ai);
      if (j <= k) sum[i] += ai;
    }
    t[i] = min(k, ti);
    long long sum = 0;
    for (auto& it : a[i]) {
      sum += it;
      it = sum;
    }
    a[i].resize(k + 1);
    long long ma = 0;
    for (auto& it : a[i]) {
      ma = max(ma, it);
      it = ma;
    }
  }
  vector<long long> rest = dfs(1, n);
  cout << rest[k] << endl;
  return 0;
}
