#include <bits/stdc++.h>
using namespace std;
vector<long long> v[3005];
long long f[20][3005], ans;
int n, k;
void solve(int l, int r, int d) {
  if (l == r) {
    for (int i = (int)(0); i <= (int)(v[l].size() - 1); i++)
      if (i + 1 <= k) ans = max(ans, v[l][i] + f[d][k - i - 1]);
    return;
  }
  int mid = (l + r) / 2;
  memcpy(f[d + 1], f[d], sizeof(f[d]));
  for (int i = (int)(mid + 1); i <= (int)(r); i++) {
    long long v1 = v[i].size(), v2 = v[i][v1 - 1];
    for (int j = (int)(k - v1); j >= (int)(0); j--)
      f[d + 1][j + v1] = max(f[d + 1][j + v1], f[d + 1][j] + v2);
  }
  solve(l, mid, d + 1);
  memcpy(f[d + 1], f[d], sizeof(f[d]));
  for (int i = (int)(l); i <= (int)(mid); i++) {
    long long v1 = v[i].size(), v2 = v[i][v1 - 1];
    for (int j = (int)(k - v1); j >= (int)(0); j--)
      f[d + 1][j + v1] = max(f[d + 1][j + v1], f[d + 1][j] + v2);
  }
  solve(mid + 1, r, d + 1);
}
int main() {
  scanf("%d%d", &n, &k);
  for (int i = (int)(1); i <= (int)(n); i++) {
    int t;
    scanf("%d", &t);
    v[i].resize(t);
    for (int j = (int)(0); j <= (int)(t - 1); j++) scanf("%lld", &v[i][j]);
    for (int j = (int)(1); j <= (int)(t - 1); j++) v[i][j] += v[i][j - 1];
  }
  solve(1, n, 0);
  cout << ans << endl;
}
