#include <bits/stdc++.h>
using namespace std;
long long n, m;
long long dp[102][10005];
long long fwd[105][105];
long long ar[105][105];
long long solve(long long row, long long rem) {
  if (row > n || rem == m) {
    return 0;
  }
  if (dp[row][rem] != -1) return dp[row][rem];
  long long i, ans = 0;
  ans = max(ans, solve(row + 1, rem));
  for (i = 1; i <= ar[row][0]; i++) {
    if (rem + i <= m) {
      ans = max(ans, solve(row + 1, rem + i) + ar[row][i]);
    } else
      break;
  }
  return dp[row][rem] = ans;
}
int main() {
  long long tc, test, i, j, k, ans;
  scanf("%lld %lld", &n, &m);
  for (i = 1; i <= n; i++) {
    scanf("%lld", &ar[i][0]);
    for (j = 1; j <= ar[i][0]; j++) {
      scanf("%lld", &ar[i][j]);
      fwd[i][j] = fwd[i][j - 1] + ar[i][j];
    }
    for (j = 1; j <= ar[i][0]; j++) {
      ar[i][j] = 0;
      for (k = 0; k <= j; k++) {
        ar[i][j] = max(ar[i][j], fwd[i][k] + fwd[i][ar[i][0]] -
                                     fwd[i][ar[i][0] - (j - k)]);
      }
    }
  }
  memset(dp, -1, sizeof dp);
  ans = solve(1, 0);
  printf("%lld\n", ans);
  return 0;
}
