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