#include <bits/stdc++.h>
using namespace std;
int main() {
  int t, n, m;
  t = 1;
  while (t--) {
    cin >> n >> m;
    vector<vector<int>> dp(101, vector<int>(10001, 0));
    int sum = 0;
    for (int i = 1; i <= n; i++) {
      int num;
      cin >> num;
      sum += num;
      vector<int> a(num + 1, 0), prefsum(num + 1, 0), suffsum(num + 1, 0),
          maxsum(num + 1, 0);
      for (int j = 1; j <= num; j++) {
        cin >> a[j];
        prefsum[j] = prefsum[j - 1] + a[j];
      }
      for (int j = 1; j <= num; j++) {
        suffsum[j] = suffsum[j - 1] + a[num - j + 1];
      }
      for (int j = 1; j <= num; j++) {
        maxsum[j] = 0;
        for (int k = 0; k <= j; k++) {
          maxsum[j] = max(maxsum[j], prefsum[k] + suffsum[j - k]);
        }
      }
      for (int j = 1; j <= min(sum, m); j++) {
        for (int k = 0; k <= min(num, j); k++) {
          dp[i][j] = max(dp[i - 1][j - k] + maxsum[k], dp[i][j]);
        }
      }
    }
    cout << dp[n][m] << "\n";
  }
  return 0;
}
