#include <bits/stdc++.h>
using namespace std;
void readi(int &x) {
  int v = 0, f = 1;
  char c = getchar();
  while (!isdigit(c) && c != '-') c = getchar();
  if (c == '-')
    f = -1;
  else
    v = v * 10 + c - '0';
  while (isdigit(c = getchar())) v = v * 10 + c - '0';
  x = v * f;
}
void readll(long long &x) {
  long long v = 0ll, f = 1ll;
  char c = getchar();
  while (!isdigit(c) && c != '-') c = getchar();
  if (c == '-')
    f = -1;
  else
    v = v * 10 + c - '0';
  while (isdigit(c = getchar())) v = v * 10 + c - '0';
  x = v * f;
}
void readc(char &x) {
  char c;
  while ((c = getchar()) == ' ')
    ;
  x = c;
}
void writes(string s) { puts(s.c_str()); }
void writeln() { writes(""); }
void writei(int x) {
  if (!x) putchar('0');
  char a[25];
  int top = 0;
  while (x) {
    a[++top] = (x % 10) + '0';
    x /= 10;
  }
  while (top) {
    putchar(a[top]);
    top--;
  }
}
void writell(long long x) {
  if (!x) putchar('0');
  char a[25];
  int top = 0;
  while (x) {
    a[++top] = (x % 10) + '0';
    x /= 10;
  }
  while (top) {
    putchar(a[top]);
    top--;
  }
}
int n, m, i, l, j, k, dp[105][105][105], a[105][105], sz[105], s[105][105],
    f[105][10005], sum[105];
int main() {
  ios::sync_with_stdio(false);
  ;
  cin >> n >> m;
  for (i = 1; i <= n; i++) {
    cin >> sz[i];
    for (j = 1; j <= sz[i]; j++) cin >> a[i][j], sum[i] += a[i][j];
  }
  for (i = 1; i <= n; i++) {
    s[i][sz[i]] = sum[i];
    for (l = 1; l <= sz[i]; l++) {
      for (j = 1; j + l - 1 <= sz[i]; j++) {
        k = j + l - 1;
        dp[i][j][k] = max(dp[i][j + 1][k] + a[i][j], dp[i][j][k - 1] + a[i][k]);
        s[i][sz[i] - l] = max(s[i][sz[i] - l], sum[i] - dp[i][j][k]);
      }
    }
  }
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= m; j++) {
      f[i][j] = f[i - 1][j];
      for (k = 1; k <= sz[i] && k <= j; k++) {
        f[i][j] = max(f[i - 1][j - k] + s[i][k], f[i][j]);
      }
    }
  }
  cout << f[n][m] << endl;
  return 0;
}
