#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-6;
const int INF = 2e9;
const long long LNF = 9e18;
const int mod = 1e9 + 7;
const int maxn = 1e4 + 10;
int n, m;
int dp[maxn];
int a[105][105], sum[105][105], s[105][105];
void init() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i][0]);
    for (int j = 1; j <= a[i][0]; j++) scanf("%d", &a[i][j]);
  }
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= a[i][0]; j++) sum[i][j] = sum[i][j - 1] + a[i][j];
  for (int i = 1; i <= n; i++)
    for (int l = 0; l <= a[i][0]; l++)
      for (int r = 0; l + r <= a[i][0]; r++)
        s[i][l + r] =
            max(s[i][l + r], sum[i][l] + sum[i][a[i][0]] - sum[i][a[i][0] - r]);
}
void solve() {
  for (int i = 1; i <= n; i++)
    for (int j = m; j >= 1; j--)
      for (int k = 1; k <= min(j, a[i][0]); k++)
        dp[j] = max(dp[j], s[i][k] + dp[j - k]);
  cout << dp[m] << endl;
}
int main() {
  init();
  solve();
}
