#include <bits/stdc++.h>
using namespace std;
long long a[105][105], presm[105][105], num[105], dp[105][10005], dp1[105][105];
int main() {
  iostream::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  long long n, m;
  cin >> n >> m;
  for (long long i = (0); i < (n); ++i) {
    cin >> num[i];
    for (long long j = (1); j < (num[i] + 1); ++j) {
      cin >> a[i][j];
      presm[i][j] = a[i][j];
    }
  }
  for (long long i = (0); i < (n); ++i) {
    for (long long j = (2); j < (num[i] + 1); ++j) {
      presm[i][j] += presm[i][j - 1];
    }
  }
  for (long long i = (0); i < (n); ++i) {
    for (long long j = (0); j < (min(num[i], m) + 1); ++j) {
      for (long long k = (0); k < (j + 1); ++k) {
        dp1[i][j] = max(dp1[i][j], presm[i][k] + presm[i][num[i]] -
                                       presm[i][num[i] - (j - k)]);
      }
    }
  }
  for (long long i = (0); i < (num[0] + 1); ++i) {
    dp[0][i] = dp1[0][i];
  }
  long long sm = num[0];
  for (long long i = (1); i < (n); ++i) {
    sm += num[i];
    for (long long j = (0); j < (m + 1); ++j) {
      for (long long k = (0); k < (min(j, num[i]) + 1); ++k) {
        dp[i][j] = max(dp[i][j], dp[i - 1][j - k] + dp1[i][k]);
      }
    }
  }
  cout << dp[n - 1][m];
}
