#include <bits/stdc++.h>
#pragma hdrstop
#pragma argsused
using namespace std;
int pl[101][101];
int best[101][101];
int mx[101][101];
int s[101];
int dp[101][100001];
int main(int argc, char* argv[]) {
  int n, m, k, l, bst;
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    cin >> s[i];
    for (int j = 0; j < s[i]; j++) {
      cin >> pl[i][j];
    }
    mx[0][0] = 0;
    for (int j = 1; j <= s[i]; j++) {
      mx[0][j] = mx[0][j - 1] + pl[i][s[i] - j];
      mx[j][0] = mx[j - 1][0] + pl[i][j - 1];
    }
    for (int j = 0; j <= s[i]; j++) {
      bst = 0;
      for (k = j, l = 0; l <= j; l++, k--) {
        mx[l][k] = mx[0][k] + mx[l][0];
        if (mx[l][k] > bst) bst = mx[l][k];
      }
      best[i][j] = bst;
    }
  }
  for (int j = 0; j <= s[0]; j++) {
    dp[0][j] = best[0][j];
  }
  for (int i = 1; i < n; i++) {
    dp[i][0] = 0;
  }
  for (int i = 1; i < n; i++)
    for (int j = 1; j <= m; j++) {
      dp[i][j] = dp[i - 1][j];
      for (int k = 0; k <= min(j, s[i]); k++) {
        dp[i][j] = max(best[i][k] + dp[i - 1][j - k], dp[i][j]);
      }
    }
  cout << dp[n - 1][m];
  return 0;
}
