#include <bits/stdc++.h>
const int N = 105, M = 1e4 + 5;
using namespace std;
int n, m, s[N], a[N], f[M];
int main() {
  cin >> n >> m;
  for (int i = 1; i <= n; ++i) {
    int x;
    cin >> x;
    for (int j = 1; j <= x; ++j) {
      cin >> a[j];
      a[j] += a[j - 1];
    }
    memset(s, 0, sizeof(s));
    for (int j = 0; j <= x - 1; ++j)
      for (int k = j; k <= x; ++k)
        s[x + j - k] = max(s[x + j - k], a[x] + a[j] - a[k]);
    for (int j = m; j >= 1; --j)
      for (int k = min(x, j); k >= 1; --k) f[j] = max(f[j], f[j - k] + s[k]);
  }
  cout << f[m];
  return 0;
}
