#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
using namespace std;
const int N = 105;
const int M = (int)1e4 + 5;
const int INF = 0x3f3f3f3f;
int sz[N];
int a[N][N];
int best[N][N];
int dp[N][M];
int main() {
  int n, m;
  cin >> n >> m;
  for (int polka = 1; polka <= n; polka++) {
    scanf("%d", &sz[polka]);
    for (int j = 1; j <= sz[polka]; j++) {
      scanf("%d", &a[polka][j]);
    }
  }
  for (int polka = 1; polka <= n; polka++) {
    vector<int> pref(N, 0);
    vector<int> suf(N, 0);
    int SZ = sz[polka];
    for (int i = 1; i <= SZ; i++) {
      pref[i] = pref[i - 1] + a[polka][i];
    }
    for (int i = SZ; i >= 1; i--) {
      suf[i] = suf[i + 1] + a[polka][i];
    }
    for (int len = 1; len <= SZ; len++) {
      for (int l = 0; l <= len; l++) {
        int r = len - l;
        best[polka][len] = max(best[polka][len], pref[l] + suf[SZ - r + 1]);
      }
    }
  }
  memset(dp, -INF, sizeof dp);
  dp[0][0] = 0;
  for (int polka = 1; polka <= n; polka++) {
    dp[polka][0] = 0;
    for (int avr = 1; avr <= m; avr++) {
      int &res = dp[polka][avr];
      for (int want = 0; want <= min(avr, sz[polka]); want++) {
        res = max(res, dp[polka - 1][avr - want] + best[polka][want]);
      }
    }
  }
  printf("%d", dp[n][m]);
}
