#include <bits/stdc++.h>
using namespace std;
mt19937 rng(time(0));
uniform_int_distribution<int> uid(-1e9, 1e9);
vector<int> v[101];
int p[101][101], d[101][101], dp[2][10001];
int rec(int l, int r, int i, int k, int x) {
  if (r < l) return 0;
  if (d[l][r]) return d[l][r];
  d[l][r] = min(rec(l + 1, r, i, k + 1, x) + v[i][l],
                rec(l, r - 1, i, k + 1, x) + v[i][r]);
  p[i][k] = max(p[i][k], x - d[l][r]);
  return d[l][r];
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, m, k;
  cin >> n >> m;
  for (int i = 0; i < n; ++i) {
    cin >> k;
    v[i].resize(k);
    for (auto& j : v[i]) cin >> j, p[i][k] += j;
    for (int j = 0; j < k; ++j) fill(d[j], d[j] + k + 1, 0);
    rec(0, k - 1, i, 0, p[i][k]);
  }
  for (int i = 0; i < n; ++i) {
    swap(dp[0], dp[1]);
    for (int j = 0; j <= m; ++j) {
      dp[1][j] = dp[0][j];
      for (k = 0; k <= min(j, int(v[i].size())); ++k)
        dp[1][j] = max(dp[1][j], dp[0][j - k] + p[i][k]);
    }
  }
  cout << dp[1][m];
}
