#include <bits/stdc++.h>
using namespace std;
const int N = 105, M = 1e4 + 5;
long long n, m, len[N], dp[N][M];
vector<vector<long long>> sum, fSum;
long long solve(long long idx, long long lefte) {
  if (lefte == 0) return 0;
  if (idx >= n) return -1e9;
  if (dp[idx][lefte] != -1) return dp[idx][lefte];
  long long ans = -1e9;
  for (int i = 0; i <= min(lefte, len[idx]); i++)
    ans = max(ans, solve(idx + 1, lefte - i) + fSum[idx][i]);
  dp[idx][lefte] = ans;
  return dp[idx][lefte];
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  sum.resize(n + 1);
  fSum.resize(n + 1);
  for (int i = 0; i < n; i++) {
    cin >> len[i];
    sum[i].resize(len[i] + 1);
    fSum[i].resize(len[i] + 1);
    for (int j = 0; j < len[i]; j++) {
      cin >> sum[i][j];
      if (j) sum[i][j] += sum[i][j - 1];
    }
    for (int j = 0; j <= len[i]; j++) {
      fSum[i][j] = 0;
      for (int k = 0; k <= j; k++) {
        long long st = (k - 1 >= 0 ? sum[i][k - 1] : 0);
        long long en =
            sum[i][len[i] - 1] -
            (len[i] - 1 - j + k >= 0 ? sum[i][len[i] - 1 - j + k] : 0);
        fSum[i][j] = max(fSum[i][j], st + en);
      }
    }
  }
  memset(dp, -1, sizeof dp);
  cout << solve(0, m);
  return 0;
}
