#include <bits/stdc++.h>
using namespace std;
int rowlength[101];
int cumulativeSum[101];
int cumulativeNumElem[101];
int removalOrder[101][101];
int dp[101][10005];
int n;
int rec(int i, int m) {
  if (m >= cumulativeNumElem[i]) {
    dp[i][m] = cumulativeSum[i];
    return dp[i][m];
  }
  if (m == 0) {
    dp[i][m] = 0;
    return dp[i][m];
  }
  if (i == n - 1) {
    dp[i][m] = removalOrder[i][m - 1];
    return dp[i][m];
  }
  if (dp[i][m] != -1) {
    return dp[i][m];
  }
  int ans = 0;
  ans = rec(i + 1, m);
  for (int j = 1; j <= rowlength[i]; j++) {
    if (m >= j) {
      int currvalue = removalOrder[i][j - 1] + rec(i + 1, m - j);
      ans = ((ans) > (currvalue) ? (ans) : (currvalue));
    }
  }
  dp[i][m] = ans;
  return dp[i][m];
}
void solve() {
  int m;
  cin >> n >> m;
  int shelves[101][101];
  for (int i = 0; i < n; i++) {
    cin >> rowlength[i];
    int csum = 0;
    for (int j = 0; j < rowlength[i]; j++) {
      cin >> shelves[i][j];
      csum += shelves[i][j];
    }
    cumulativeNumElem[i] = rowlength[i];
    cumulativeSum[i] = csum;
  }
  for (int i = 0; i < n; i++) {
    int prefixsum[101];
    int prefix = 0;
    prefixsum[0] = 0;
    for (int j = 0; j < rowlength[i]; j++) {
      prefix += shelves[i][j];
      prefixsum[j + 1] = prefix;
    }
    for (int j = 1; j <= rowlength[i]; j++) {
      removalOrder[i][j - 1] = 0;
      for (int k = 0; k <= j; k++) {
        int currentsuffix =
            prefixsum[rowlength[i]] - prefixsum[rowlength[i] - j + k];
        int currentprefix = prefixsum[k];
        int currentvalue = currentprefix + currentsuffix;
        removalOrder[i][j - 1] = ((removalOrder[i][j - 1]) > (currentvalue)
                                      ? (removalOrder[i][j - 1])
                                      : (currentvalue));
      }
    }
  }
  for (int i = n - 2; i >= 0; i--) {
    cumulativeSum[i] = cumulativeSum[i] + cumulativeSum[i + 1];
    cumulativeNumElem[i] = cumulativeNumElem[i] + cumulativeNumElem[i + 1];
  }
  memset(dp, -1, sizeof(dp));
  cout << rec(0, m) << endl;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  solve();
  return 0;
}
