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