#include <bits/stdc++.h>
using namespace std;
int n, m;
int a[120], x[120][120], q[120][120], h[120][120], w[120][120], dp[120][10010];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    for (int j = 1; j <= a[i]; j++) cin >> x[i][j];
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= a[i]; j++) q[i][j] = q[i][j - 1] + x[i][j];
  }
  for (int i = 1; i <= n; i++) {
    int tmp = 1;
    for (int j = a[i]; j >= 1; j--) {
      h[i][tmp] = h[i][tmp - 1] + x[i][j];
      tmp++;
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= a[i]; j++) {
      w[i][j] = max(q[i][j], h[i][j]);
      for (int k = 1; k < j; k++) {
        w[i][j] = max(w[i][j], q[i][k] + h[i][j - k]);
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      for (int k = 0; k <= min(j, a[i]); k++) {
        dp[i][j] = max(dp[i][j], dp[i - 1][j - k] + w[i][k]);
      }
    }
  }
  cout << dp[n][m] << endl;
  return 0;
}
