#include <bits/stdc++.h>
using namespace std;
int f[110][110], c[110], a[110][110], sum[110][110], g[110][10010];
int n, m;
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &c[i]);
    for (int j = 1; j <= c[i]; j++) {
      scanf("%d", &a[i][j]);
      sum[i][j] = sum[i][j - 1] + a[i][j];
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= c[i]; j++) {
      for (int k = 0; k <= j; k++) {
        f[i][j] =
            max(f[i][j], sum[i][k] + sum[i][c[i]] - sum[i][c[i] - (j - k)]);
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      for (int k = 0; k <= min(j, c[i]); k++) {
        g[i][j] = max(g[i][j], g[i - 1][j - k] + f[i][k]);
      }
    }
  }
  printf("%d\n", g[n][m]);
  return 0;
}
