#include <bits/stdc++.h>
using namespace std;
int a[110];
int g[110];
int f[10100];
int n, m, s, nn;
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i <= m; ++i) f[i] = -999999999;
  s = 0;
  f[0] = 0;
  for (int ii = 1; ii <= n; ++ii) {
    scanf("%d", &nn);
    for (int i = 1; i <= nn; ++i) scanf("%d", &a[i]);
    for (int i = 2; i <= nn; ++i) a[i] += a[i - 1];
    for (int i = 0; i <= nn; ++i) {
      g[i] = 0;
      for (int j = 0; j <= i; ++j)
        g[i] = max(g[i], a[j] + a[nn] - a[nn - (i - j)]);
    }
    for (int i = s; i >= 0; --i)
      if (f[i] >= 0)
        for (int j = 1; j <= nn; ++j)
          if (f[i] + g[j] > f[i + j]) f[i + j] = f[i] + g[j];
    s += nn;
  }
  printf("%d\n", f[m]);
  return 0;
}
