#include <bits/stdc++.h>
using namespace std;
int main() {
  int i, j, k, x, n, m, mk, d, s[101], dp[10001], dp2[10001];
  cin >> n >> m;
  dp[0] = s[0] = 0;
  for (i = 1; i <= m; i++) dp[i] = -100000000;
  for (i = 1; i <= n; i++) {
    cin >> k;
    for (j = 0; j <= m; j++) dp2[j] = dp[j];
    for (j = 1; j <= k; j++) {
      cin >> x;
      s[j] = s[j - 1] + x;
    }
    for (j = 1; j <= min(k, m); j++) {
      d = 0;
      for (x = 0; x <= j; x++) d = max(d, s[x] + s[k] - s[k - (j - x)]);
      for (x = m; x >= j; x--) dp[x] = max(dp[x], dp2[x - j] + d);
    }
  }
  cout << dp[m];
  return 0;
}
