#include <bits/stdc++.h>
int a[200][200];
int b[200][200];
int d[200][200];
int c[200][20000];
int n, m, i, j, k, s, q;
void mtavari() {
  for (i = 1; i <= n; i++)
    for (j = 1; j <= a[i][0]; j++) d[i][j] = d[i][j - 1] + a[i][j];
  for (i = 1; i <= n; i++)
    for (j = 1; j <= a[i][0]; j++) {
      s = 0;
      for (k = 0; k <= j; k++)
        if (s < d[i][k] + d[i][a[i][0]] - d[i][a[i][0] - j + k])
          s = d[i][k] + d[i][a[i][0]] - d[i][a[i][0] - j + k];
      b[i][j] = s;
    }
  for (i = 1; i <= a[1][0]; i++) c[1][i] = b[1][i];
  s = a[1][0];
  for (i = 2; i <= n; i++) {
    s += a[i][0];
    for (j = 1; j <= s; j++) {
      q = 0;
      for (k = 0; k <= a[i][0]; k++)
        if (j >= k && j - k <= s - a[i][0])
          if (q < c[i - 1][j - k] + b[i][k]) q = c[i - 1][j - k] + b[i][k];
      c[i][j] = q;
    }
  }
}
int main() {
  scanf("%d%d\n", &n, &m);
  for (i = 1; i <= n; i++) {
    scanf("%d", &a[i][0]);
    for (j = 1; j <= a[i][0]; j++) scanf("%d", &a[i][j]);
  }
  mtavari();
  printf("%d", c[n][m]);
  return 0;
}
