#include <bits/stdc++.h>
using namespace std;
int ntest = 0, test = 0;
inline void init();
inline void run();
inline void stop() { ntest = test - 1; }
int main() {
  init();
  while (++test <= ntest) {
    run();
  }
  return 0;
}
const int INF = (int)1E9 + 5;
const double EPS = 1E-11;
const long long MOD = 1000000007LL;
const int dx[] = {-1, 0, 0, 1};
const int dy[] = {0, -1, 1, 0};
inline void init() { ntest = 1; }
int n, m;
int numItem[105], valueOf[105][105], dpEachShelf[105][105],
    dpManyShelves[105][10005];
int l[105], r[105];
inline void run() {
  scanf("%d%d", &n, &m);
  for (int whatShelf = (1); whatShelf <= (n); whatShelf++) {
    scanf("%d", &numItem[whatShelf]);
    for (int whatItem = (1); whatItem <= (numItem[whatShelf]); whatItem++) {
      scanf("%d", &valueOf[whatShelf][whatItem]);
    }
  }
  memset((dpEachShelf), (0), sizeof(dpEachShelf));
  memset((dpManyShelves), (0), sizeof(dpManyShelves));
  for (int whatShelf = (1); whatShelf <= (n); whatShelf++) {
    l[0] = 0;
    for (int rightMost = (1); rightMost <= (numItem[whatShelf]); rightMost++) {
      l[rightMost] = l[rightMost - 1] + valueOf[whatShelf][rightMost];
    }
    r[0] = 0;
    for (int leftMost = (numItem[whatShelf]); leftMost >= (1); leftMost--) {
      r[numItem[whatShelf] + 1 - leftMost] =
          r[numItem[whatShelf] - leftMost] + valueOf[whatShelf][leftMost];
    }
    for (int pick = (1); pick <= (numItem[whatShelf]); pick++) {
      for (int pickLeft = (0); pickLeft <= (pick); pickLeft++) {
        dpEachShelf[whatShelf][pick] =
            max(dpEachShelf[whatShelf][pick], l[pickLeft] + r[pick - pickLeft]);
      }
    }
  }
  int total = 0;
  for (int whatShelf = (1); whatShelf <= (n); whatShelf++) {
    total += numItem[whatShelf];
    int bound = min(m, total);
    for (int pickAll = (0); pickAll <= (bound); pickAll++) {
      int thisBound = min(pickAll, numItem[whatShelf]);
      for (int pickThis = (0); pickThis <= (thisBound); pickThis++) {
        dpManyShelves[whatShelf][pickAll] =
            max(dpManyShelves[whatShelf][pickAll],
                dpManyShelves[whatShelf - 1][pickAll - pickThis] +
                    dpEachShelf[whatShelf][pickThis]);
      }
    }
  }
  printf("%d\n", dpManyShelves[n][m]);
}
