#include <bits/stdc++.h>
using namespace std;
int n, m, b[102], k[102], a[102][102], sum_all, min_sum, sum, dp[102][10002];
int main() {
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    cin >> k[i];
    sum_all = 0;
    for (int j = 0; j < k[i]; j++) {
      cin >> b[j];
      sum_all += b[j];
    }
    for (int len = 0; len <= k[i]; len++) {
      sum = 0;
      for (int j = 0; j < len; j++) {
        sum += b[j];
      }
      min_sum = sum;
      for (int j = len; j < k[i]; j++) {
        sum += b[j];
        sum -= b[j - len];
        min_sum = min(min_sum, sum);
      }
      a[i][k[i] - len] = sum_all - min_sum;
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      for (int now = 0; now <= min(k[i], j); now++) {
        if (!(i > 1 && j - now > 1 && dp[i - 1][j - now] == 0)) {
          dp[i][j] = max(dp[i][j], dp[i - 1][j - now] + a[i][now]);
        }
      }
    }
  }
  cout << dp[n][m];
  return 0;
}
