#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = double;
using pll = pair<ll, ll>;
using vll = vector<ll>;
using vpll = vector<pll>;
using vvll = vector<vll>;
int shelf[105][105];
int vals[105][105];
int cnts[105];
int dp1[105][105][105];
void rec1(int s, int l, int r, int res) {
  if (dp1[s][l][r] != -1) return;
  dp1[s][l][r] = res;
  if (r == l) return;
  rec1(s, l + 1, r, res + vals[s][l]);
  rec1(s, l, r - 1, res + vals[s][r - 1]);
}
int maxForShelf[105][105];
int mtx[105][10005];
int rec2(int shelf, int cnt, int totalShelves) {
  if (cnt == 0) return 0;
  if (cnt < 0) return -(int)(1 << 26);
  if (mtx[shelf][cnt] != 0) return mtx[shelf][cnt];
  if (shelf == totalShelves - 1) {
    if (cnt > cnts[shelf]) return -(int)(1 << 26);
    mtx[shelf][cnt] = maxForShelf[shelf][cnt];
    return maxForShelf[shelf][cnt];
  }
  int res = 0;
  for (ll i = 0; i < (ll)min(cnts[shelf] + 1, cnt + 1); ++i) {
    res = max(rec2(shelf + 1, cnt - i, totalShelves) + maxForShelf[shelf][i],
              res);
  }
  mtx[shelf][cnt] = res;
  return res;
}
int main() {
  ios::sync_with_stdio(0);
  cout.tie(0);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  for (ll i = 0; i < (ll)n; ++i) {
    cin >> cnts[i];
    for (ll j = 0; j < (ll)cnts[i]; ++j) {
      cin >> vals[i][j];
    }
  }
  memset(dp1, -1, 105 * 105 * 105 * sizeof(int));
  for (ll i = 0; i < (ll)n; ++i) rec1(i, 0, cnts[i], 0);
  for (ll i = 0; i < (ll)n; ++i) {
    for (ll j = 0; j < (ll)cnts[i] + 1; ++j) {
      for (ll k = 0; k < (ll)cnts[i] + 1; ++k) {
        if (j + k > cnts[i]) continue;
        maxForShelf[i][j + k] =
            max(maxForShelf[i][j + k], dp1[i][j][cnts[i] - k]);
      }
    }
  }
  cout << rec2(0, m, n) << endl;
  return 0;
}
