#include <bits/stdc++.h>
using namespace std;
int f[105][105];
int a[10005], b[10005];
int num[105];
int n, m;
int s[105];
int main() {
  int i, j, k;
  scanf("%d%d", &n, &m);
  for (i = 1; i <= n; i++) {
    scanf("%d", num + i);
    for (j = 1; j <= num[i]; j++) {
      scanf("%d", s + j);
      s[j] += s[j - 1];
    }
    for (j = 1; j <= num[i]; j++) {
      for (k = 0; k <= j; k++)
        f[i][j] = max(f[i][j], s[k] + s[num[i]] - s[num[i] - j + k]);
    }
  }
  for (i = 1; i <= num[1]; i++) a[i] = f[1][i];
  for (i = 2; i <= n; i++) {
    memcpy(b, a, sizeof(a));
    for (j = 1; j <= num[i]; j++) {
      for (k = j; k <= m; k++)
        if (k - j == 0 || b[k - j]) {
          b[k] = max(b[k], a[k - j] + f[i][j]);
        }
    }
    memcpy(a, b, sizeof(b));
  }
  printf("%d\n", a[m]);
}
