#include <bits/stdc++.h>
using namespace std;
int n, m, c[105];
int sum[105][10005], h[105][10005], f[105][10005];
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &c[i]);
    sum[i][0] = 0;
    for (int j = 1; j <= c[i]; j++) {
      int x;
      scanf("%d", &x);
      sum[i][j] = sum[i][j - 1] + x;
    }
    for (int j = 1; j <= c[i]; j++)
      for (int k = 0; k <= j; k++)
        h[i][j] = max(h[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++)
        f[i][j] = max(f[i][j], f[i - 1][j - k] + h[i][k]);
  printf("%d\n", f[n][m]);
  return 0;
}
