#include <bits/stdc++.h>
using namespace std;
int n, m, ps[103], sz[103], A[10003], op[103][10003], a, tmp;
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    cin >> sz[i];
    for (int j = 1; j <= sz[i]; j++) {
      cin >> a;
      ps[j] = ps[j - 1] + a;
    }
    ps[sz[i] + 1] = ps[sz[i]];
    for (int j = 0; j <= sz[i]; j++) {
      for (int k = j + 1; k <= sz[i] + 1; k++) {
        op[i][j + sz[i] + 1 - k] =
            max(op[i][j + sz[i] + 1 - k], ps[j] + ps[sz[i]] - ps[k - 1]);
      }
    }
  }
  memset(A, -1, sizeof A);
  A[0] = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = m; j >= 0; j--) {
      for (int k = 0; k <= sz[i]; k++) {
        if (j >= k && A[j - k] > -1) {
          A[j] = max(A[j], A[j - k] + op[i][k]);
        }
      }
    }
  }
  if (A[m] > -1)
    cout << A[m] << '\n';
  else
    cout << 0 << '\n';
}
