#include <bits/stdc++.h>
using namespace std;
const int Maxv = 110;
int n, m;
int val[Maxv][Maxv * Maxv];
int org[Maxv][Maxv];
int dp[Maxv][Maxv * Maxv];
int Len[Maxv];
int main() {
  int i, j, k;
  cin >> n >> m;
  for (i = 1; i <= n; i++) {
    scanf("%d", &Len[i]);
    for (j = 1; j <= Len[i]; j++) scanf("%d", &org[i][j]);
    int sum1 = 0;
    for (j = 0; j <= Len[i]; j++) {
      int sum2 = 0;
      sum1 += org[i][j];
      for (k = Len[i] + 1; k > j; k--) {
        sum2 += org[i][k];
        int tcost = j + Len[i] + 1 - k;
        val[i][tcost] = max(sum1 + sum2, val[i][tcost]);
      }
    }
    for (k = m; k >= 1; k--) {
      for (j = 0; j <= Len[i] && j <= k; j++) {
        dp[i][k] = max(dp[i][k], dp[i - 1][k - j] + val[i][j]);
      }
    }
  }
  printf("%d\n", dp[n][m]);
  return 0;
}
