#include <bits/stdc++.h>
using namespace std;
long long matrix[105][10005];
int main() {
  int n;
  long m;
  cin >> n >> m;
  vector<vector<long long> > table(n + 1);
  for (int i = 1; i <= n; i++) {
    int c;
    cin >> c;
    table[i].resize(c + 1, 0);
    for (int j = 1; j <= c; j++) {
      long long a;
      cin >> a;
      table[i][j] = table[i][j - 1] + a;
    }
  }
  vector<vector<long long> > sums(n + 1);
  for (int i = 1; i <= n; i++) {
    int dd = table[i].size() - 1;
    for (int j = 0; j <= dd; j++) {
      long long add = 0;
      for (int k = 0; k <= j; k++)
        add = max(
            table[i][k] - table[i][0] + table[i][dd] - table[i][dd - (j - k)],
            add);
      sums[i].push_back(add);
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j < sums[i].size(); j++)
      for (long k = 0; k <= m - j; k++)
        matrix[i][k + j] = max(matrix[i - 1][k] + sums[i][j], matrix[i][k + j]);
  }
  cout << matrix[n][m];
  return 0;
}
