#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) {
  if (a == 0)
    return b;
  else
    return gcd(b % a, a);
}
int n, m;
int f[101][101], ans[10001];
int k[1000], a[1000], s[1000];
int main() {
  srand(time(NULL));
  ios_base::sync_with_stdio(0);
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    cin >> k[i];
    for (int j = 1; j <= k[i]; j++) cin >> a[j];
    s[0] = 0;
    for (int j = 1; j <= k[i]; j++) s[j] = s[j - 1] + a[j];
    for (int j = 0; j <= k[i]; j++) f[i][j] = 0;
    for (int l = 0; l <= k[i]; l++)
      for (int r = 0; r <= k[i] - l; r++)
        f[i][l + r] = max(f[i][l + r], s[k[i]] - s[k[i] - r] + s[l]);
  }
  for (int i = 0; i <= m; i++) ans[i] = 0;
  for (int i = 1; i <= n; i++)
    for (int j = m; j >= 0; j--)
      for (int ii = 1; ii <= k[i]; ii++)
        if (j + ii <= m) ans[j + ii] = max(ans[j + ii], ans[j] + f[i][ii]);
  cout << ans[m] << endl;
  return 0;
}
