#include <bits/stdc++.h>
using namespace std;
const int INF = (int)1e9;
const long long IINF = 1LL << 62;
const int maxn = 10000005;
vector<int> calc(vector<int> a) {
  int n = a.size() + 1;
  vector<int> front(n), back(n), res(n);
  for (int i = 1; i < n; i++) front[i] = front[i - 1] + a[i - 1];
  for (int i = 1; i < n; i++) back[i] = back[i - 1] + a[n - i - 1];
  for (int i = 1; i < n; i++) {
    for (int j = 0; j <= i; j++) res[i] = max(res[i], front[j] + back[i - j]);
  }
  return res;
}
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> ans(m + 1);
  for (int i = 0; i < n; i++) {
    int k;
    cin >> k;
    vector<int> tmp(k);
    for (int j = 0; j < k; j++) cin >> tmp[j];
    tmp = calc(tmp);
    for (int j = m; j >= 0; --j) {
      for (int k = 1; j - k >= 0 && k < (int)tmp.size(); ++k) {
        ans[j] = max(ans[j], ans[j - k] + tmp[k]);
      }
    }
  }
  cout << ans.back();
}
