#include <bits/stdc++.h>
using namespace std;
long int n, m, ar[101][10001], dp[101][101], ans1[10001][101], temp[101];
long int dp1[10001][501];
long int solve(long int m1, long int size, long int l, long int r,
               long int ar[]) {
  if (m1 < (l + size - r)) {
    return 0;
  }
  if (l > r) {
    return -1000000000;
  }
  if (dp[l][r] != -1) {
    return dp[l][r];
  }
  return dp[l][r] = max(solve(m1, size, l + 1, r, ar) + ar[l],
                        solve(m1, size, l, r - 1, ar) + ar[r]);
}
long int solve1(long int n, long int m, long int shelf) {
  if (m == 0) {
    return 0;
  }
  if (m < 0) {
    return -1000000000;
  }
  if (shelf > n) {
    return -1000000000;
  }
  if (dp1[m][shelf] != -1) {
    return dp1[m][shelf];
  }
  long int ans = -1000000000;
  for (long int i = 1; i <= min(m, temp[shelf]); i++) {
    ans = max(ans, max(solve1(n, m - i, shelf + 1) + ans1[shelf][i],
                       solve1(n, m, shelf + 1)));
  }
  return dp1[m][shelf] = ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long int i, k, j;
  cin >> n >> m;
  for (i = 0; i < n; i++) {
    cin >> k;
    temp[i] = k;
    for (j = 0; j < k; j++) {
      cin >> ar[i][j];
    }
    for (j = 1; j <= min(k, m); j++) {
      memset(dp, -1, sizeof(dp));
      ans1[i][j] = solve(j, k, 0, k - 1, ar[i]);
    }
  }
  memset(dp1, -1, sizeof(dp1));
  cout << solve1(n, m, 0);
  return 0;
}
