#include <bits/stdc++.h>
int N, M, i, j, k, U[110], a[110], b[110], c[110], d[110][110], f[110][10010];
int main() {
  scanf("%d%d", &N, &M);
  for (i = 1; i <= N; i++) {
    scanf("%d", &U[i]);
    for (j = 1; j <= U[i]; j++) scanf("%d", &a[j]);
    b[0] = 0;
    for (j = 1; j <= U[i]; j++) b[j] = b[j - 1] + a[j];
    c[U[i] + 1] = 0;
    for (j = U[i]; j; j--) c[j] = c[j + 1] + a[j];
    for (j = 1; j <= U[i]; j++)
      for (k = 0; k <= j; k++)
        if (b[k] + c[U[i] - (j - k) + 1] > d[i][j])
          d[i][j] = b[k] + c[U[i] - (j - k) + 1];
  }
  for (i = 1; i <= N; i++)
    for (j = 0; j <= U[i]; j++)
      for (k = j; k <= M; k++)
        if (f[i - 1][k - j] + d[i][j] > f[i][k])
          f[i][k] = f[i - 1][k - j] + d[i][j];
  printf("%d\n", f[N][M]);
  return 0;
}
