#include <bits/stdc++.h>
long long mod = 1000000007;
using namespace std;
int n, m;
int preprocess[101][10001];
int a[200][200];
int size[101];
int dp[103][10005];
long long powmod(long long a, long long b) {
  long long res = 1;
  a %= mod;
  for (; b; b >>= 1) {
    if (b & 1) res = res * a % mod;
    a = a * a % mod;
  }
  return res;
}
void pre() {
  int i, j, pre = 0, suf = 0, siz, k;
  for (i = 0; i < n; i++) {
    pre = suf = 0;
    for (j = 0; j < size[i]; j++) {
      pre += a[i][j];
      preprocess[i][j + 1] = max(preprocess[i][j + 1], pre);
      suf = 0;
      for (k = size[i] - 1; k > j; k--) {
        suf += a[i][k];
        siz = size[i] - k + j + 1;
        preprocess[i][siz] = max(preprocess[i][siz], pre + suf);
      }
    }
    pre = 0;
    suf = 0;
    for (k = size[i] - 1; k >= 0; k--) {
      suf += a[i][k];
      siz = size[i] - k;
      preprocess[i][siz] = max(preprocess[i][siz], pre + suf);
    }
  }
}
int func(int curr, int left) {
  if (curr == n || left == 0) return 0;
  if (dp[curr][left] != -1) return dp[curr][left];
  int maxi = 0;
  for (int i = 0; i <= min(left, size[curr]); i++) {
    maxi = max(maxi, func(curr + 1, left - i) + preprocess[curr][i]);
  }
  return dp[curr][left] = maxi;
}
int main() {
  int i, j, fl, test;
  scanf("%d%d", &n, &m);
  memset(dp, -1, sizeof(dp));
  for (i = 0; i < n; i++) {
    scanf("%d", &size[i]);
    for (j = 0; j < size[i]; j++) {
      scanf("%d", &a[i][j]);
    }
  }
  pre();
  printf("%d\n", func(0, m));
  return 0;
}
