#include <bits/stdc++.h>
using namespace std;
int items[200][200];
int cost[200][200];
int dp[200][20000];
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= n; ++i) {
    cin >> items[i][0];
    for (int j = 1; j <= items[i][0]; ++j) {
      cin >> items[i][j];
    }
  }
  for (int i = 1; i <= n; ++i) {
    for (int j = 0; j <= items[i][0]; ++j) {
      int ans = 0;
      int now = 0;
      for (int k = 1; k <= j; ++k) now += items[i][k];
      ans = now;
      for (int k = j; k > 0; --k) {
        now -= items[i][k];
        now += items[i][items[i][0] - (j - (k - 1)) + 1];
        ans = max(ans, now);
      }
      cost[i][j] = ans;
    }
  }
  for (int i = 1; i <= n; ++i) {
    dp[i][0] = 0;
    for (int j = 1; j <= m; ++j) {
      dp[i][j] = 0;
      for (int k = 0; k <= min(j, items[i][0]); ++k)
        dp[i][j] = max(dp[i][j], cost[i][k] + dp[i - 1][j - k]);
    }
  }
  cout << dp[n][m] << endl;
  return 0;
}
