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