#include <bits/stdc++.h>
using namespace std;
const int maxn = 100 + 4;
int n, m, x[maxn], a[maxn][maxn], dp[maxn][10005], l[maxn], r[maxn];
int cnt[maxn];
int pd[maxn][maxn];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    cin >> x[i];
    fill(r, r + maxn, 0);
    fill(l, l + maxn, 0);
    for (int j = 1; j <= x[i]; j++) {
      cin >> a[i][j];
      l[j] = l[j - 1] + a[i][j];
    }
    for (int j = x[i]; j > 0; j--) {
      r[j] = r[j + 1] + a[i][j];
    }
    for (int j = 0; j <= x[i]; j++) {
      for (int k = 0; k <= j; k++) {
        pd[i][j] = max(pd[i][j], l[k] + r[x[i] - j + k + 1]);
      }
    }
    cnt[i] = cnt[i - 1] + x[i];
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j <= cnt[i]; j++) {
      for (int k = 0; k <= x[i] && k <= j; k++)
        dp[i][j] = max(dp[i][j], dp[i - 1][j - k] + pd[i][k]);
    }
  }
  cout << dp[n][m];
}
