#include <bits/stdc++.h>
using namespace std;
const double pi = 3.14159265358979323;
const double eps = 1e-8;
const int inf = 1 << 29;
int sum[110][11000], n, m;
int d[110][11000], f[1100][1100];
int dp[110][11000];
void calc(int row) {
  int tot, kn = d[row][0];
  for (int i(0); i < (kn + 1); i++) {
    if (i > m) break;
    f[row][i] = max(f[row][i], sum[row][i]);
    for (int j = kn; j > i; j--) {
      tot = i + kn - j + 1;
      if (tot > m) break;
      f[row][tot] =
          max(f[row][tot], sum[row][i] + sum[row][kn] - sum[row][j - 1]);
    }
  }
}
int main() {
  memset(f, 0, sizeof(f));
  memset(dp, 0, sizeof(dp));
  cin >> n >> m;
  for (int i(1); i < (n + 1); i++) {
    cin >> d[i][0];
    sum[i][0] = 0;
    for (int j(1); j < (d[i][0] + 1); j++) {
      cin >> d[i][j];
      sum[i][j] = sum[i][j - 1] + d[i][j];
    }
    calc(i);
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      for (int k = 0; k <= min(d[i][0], j); k++)
        dp[i][j] = max(dp[i][j], dp[i - 1][j - k] + f[i][k]);
    }
  }
  cout << dp[n][m] << endl;
  return 0;
}
