#include <bits/stdc++.h>
using namespace std;
long long n, m, val[105], c[105][105], pref[105][105], calc[105][105],
    dp[105][10005];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  for (long long i = 1; i <= n; ++i) {
    cin >> val[i];
    for (long long j = 1; j <= val[i]; ++j)
      cin >> c[i][j], pref[i][j] = pref[i][j - 1] + c[i][j];
  }
  for (long long i = 1; i <= n; ++i)
    for (long long j = 1; j <= min(m, val[i]); ++j)
      for (long long k = 0; k <= j; ++k)
        calc[i][j] = max(calc[i][j], pref[i][k] + pref[i][val[i]] -
                                         pref[i][val[i] - (j - k)]);
  long long tot = 0;
  for (long long i = 1; i <= n; ++i) {
    tot += val[i];
    for (long long j = 1; j <= min(tot, m); ++j) {
      for (long long k = 0; k <= min(j, val[i]); ++k) {
        dp[i][j] = max(dp[i][j], dp[i - 1][j - k] + calc[i][k]);
      }
    }
  }
  cout << dp[n][m] << endl;
}
