#include <bits/stdc++.h>
using namespace std;
int n, m;
int num[105];
int a[105][105], sum[105][105], mx[105][105];
int f[105][10005];
int main() {
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    cin >> num[i];
    for (int j = 1; j <= num[i]; j++) {
      cin >> a[i][j];
      sum[i][j] = sum[i][j - 1] + a[i][j];
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= num[i]; j++) {
      for (int k = 0; k <= j; k++) {
        mx[i][j] = max(mx[i][j],
                       sum[i][k] + (sum[i][num[i]] - sum[i][num[i] - (j - k)]));
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j <= m; j++) {
      int maxi = 0;
      for (int k = 0; k <= num[i] && k <= j; k++) {
        maxi = max(maxi, f[i - 1][j - k] + mx[i][k]);
      }
      f[i][j] = maxi;
    }
  }
  cout << f[n][m] << endl;
  return 0;
}
