#include <bits/stdc++.h>
using namespace std;
int n, m;
int arr[110][110];
int dp[110][11000];
int ma[110][110];
int dprec(int in, int mine) {
  int &ret = dp[in][mine];
  if (ret != -1) return ret;
  ret = 0;
  if (mine == 0 || in > n) return 0;
  int i;
  for (i = 0; i <= min(arr[in][0], mine); i++)
    ret = max(ma[in][i] + dprec(in + 1, mine - i), ret);
  return ret;
}
int main() {
  int i, j, k;
  while (cin >> n >> m) {
    memset(dp, -1, sizeof(dp));
    memset(ma, 0, sizeof(ma));
    for (i = 1; i <= n; i++) {
      cin >> arr[i][0];
      for (j = 1; j <= arr[i][0]; j++) cin >> arr[i][j];
    }
    for (i = 1; i <= n; i++) {
      int sum = 0;
      for (j = 1; j <= arr[i][0]; j++) sum += arr[i][j];
      int al = arr[i][0];
      ma[i][arr[i][0]] = sum;
      for (j = 1; j <= arr[i][0]; j++) {
        int sum1 = 0;
        for (k = j; k <= arr[i][0]; k++) {
          sum1 += arr[i][k];
          ma[i][al - (k - j + 1)] = max(ma[i][al - (k - j + 1)], sum - sum1);
        }
      }
    }
    cout << dprec(1, m) << endl;
  }
  return 0;
}
