#include <bits/stdc++.h>
using namespace std;
int dp[111][111][111];
int val[111][111];
int have[111];
int max(int a, int b) { return a > b ? a : b; }
int min(int a, int b) { return a < b ? a : b; }
int dp2[111][111];
int dp3[111][111111];
int s[111];
int main() {
  int i, j, k;
  int n, m;
  scanf("%d%d", &n, &m);
  for (i = 1; i <= n; i++) {
    int x;
    scanf("%d", &x);
    have[i] = x;
    for (j = 1; j <= x; j++) scanf("%d", &val[i][j]);
  }
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= have[i]; j++) {
      for (k = 0; k <= j; k++) {
        dp[i][j][k] = max(dp[i][j][k], dp[i][j - 1][k - 1] + val[i][k]);
        dp[i][j][k] =
            max(dp[i][j][k], dp[i][j - 1][k] + val[i][have[i] - (j - 1 - k)]);
        dp2[i][j] = max(dp2[i][j], dp[i][j][k]);
      }
    }
  }
  for (i = 1; i <= n; i++) s[i] = s[i - 1] + have[i];
  int ans = 0;
  for (i = 0; i <= n; i++) {
    for (j = 0; j <= s[i] && j <= m; j++) {
      for (k = 0; k <= have[i + 1] && j + k <= m; k++) {
        dp3[i + 1][j + k] = max(dp3[i + 1][k + j], dp3[i][j] + dp2[i + 1][k]);
      }
    }
  }
  for (i = 1; i <= n; i++) {
    ans = max(ans, dp3[i][m]);
  }
  cout << ans << endl;
  return 0;
}
