#include <bits/stdc++.h>
using namespace std;
template <class T>
void splitstr(const string &s, vector<T> &out) {
  istringstream in(s);
  out.clear();
  copy(istream_iterator<T>(in), istream_iterator<T>(), back_inserter(out));
}
template <class T>
T gcd(T a, T b) {
  return b ? gcd(b, a % b) : a;
}
static void redirect(int argc, const char **argv) {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  if (argc > 1) {
    static filebuf f;
    f.open(argv[1], ios::in);
    cin.rdbuf(&f);
    if (!cin) {
      cerr << "Failed to open '" << argv[1] << "'" << endl;
      exit(1);
    }
  }
  if (argc > 2) {
    static filebuf f;
    f.open(argv[2], ios::out | ios::trunc);
    cout.rdbuf(&f);
    if (!cout) {
      cerr << "Failed to open '" << argv[2] << "'" << endl;
    }
  }
  cin.exceptions(ios::failbit);
}
static long long recurse(int A, int B, const vector<long long> &dp,
                         const vector<vector<long long> > &pref) {
  long long ans = 0;
  int K = ((long long)(dp).size()) - 1;
  if (B - A == 1) {
    for (int i = 0; i < ((long long)(pref[A]).size()); i++)
      ans = max(ans, pref[A][i] + dp[K - i]);
  } else {
    int M = (A + B) / 2;
    vector<long long> dp2 = dp;
    for (int i = M; i < B; i++) {
      int s = ((long long)(pref[i]).size()) - 1;
      long long w = pref[i].back();
      for (int j = K; j >= s; j--) dp2[j] = max(dp2[j], dp2[j - s] + w);
    }
    ans = max(ans, recurse(A, M, dp2, pref));
    dp2 = dp;
    for (int i = A; i < M; i++) {
      int s = ((long long)(pref[i]).size()) - 1;
      long long w = pref[i].back();
      for (int j = K; j >= s; j--) dp2[j] = max(dp2[j], dp2[j - s] + w);
    }
    ans = max(ans, recurse(M, B, dp2, pref));
  }
  return ans;
}
int main(int argc, const char **argv) {
  redirect(argc, argv);
  int N, K;
  cin >> N >> K;
  vector<vector<long long> > pref(N);
  for (int i = 0; i < N; i++) {
    int t;
    cin >> t;
    pref[i].resize(t + 1);
    for (int j = 0; j < t; j++) {
      long long x;
      cin >> x;
      pref[i][j + 1] = pref[i][j] + x;
    }
    if (t > K) pref[i].resize(K + 1);
  }
  vector<long long> dp(K + 1);
  long long ans = recurse(0, N, dp, pref);
  cout << ans << '\n';
  return 0;
}
