#include <bits/stdc++.h>
using namespace std;
const int N = 105;
int n, m, a[N][N], cnt[N], sum[N][N], dp[N][N], tp[N][10005];
int main() {
  ios::sync_with_stdio(false);
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    cin >> cnt[i];
    for (int j = 1; j <= cnt[i]; j++)
      cin >> a[i][j], sum[i][j] = sum[i][j - 1] + a[i][j];
  }
  for (int h = 1; h <= n; h++)
    for (int t = 1; t <= cnt[h]; t++)
      for (int i = 0; i <= t; i++)
        dp[h][t] =
            max(dp[h][t], sum[h][i] + sum[h][cnt[h]] - sum[h][cnt[h] - t + i]);
  for (int i = 1; i <= n; i++)
    for (int j = 0; j <= m; j++)
      for (int k = 0; k <= cnt[i] && k <= j; k++)
        tp[i][j] = max(tp[i][j], tp[i - 1][j - k] + dp[i][k]);
  cout << tp[n][m] << endl;
}
