#include <bits/stdc++.h>
using namespace std;
const int N = 100 + 3;
int n, m;
int sz[N];
int a[N][N], sumL[N][N], sumR[N][N];
int mx[N][N];
int dp[10009], dp1[10009];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  for (int i = 1; i <= n; ++i) {
    cin >> sz[i];
    for (int j = 1; j <= sz[i]; ++j)
      cin >> a[i][j], sumL[i][j] = sumL[i][j - 1] + a[i][j];
    for (int j = sz[i]; j >= 1; j--) sumR[i][j] = sumR[i][j + 1] + a[i][j];
  }
  for (int t = 1; t <= n; ++t) {
    for (int sl = 1; sl <= sz[t]; ++sl)
      for (int i = 0; i <= sl; ++i)
        mx[t][sl] = max(mx[t][sl], sumL[t][i] + sumR[t][sz[t] - (sl - i) + 1]);
  }
  for (int i = 1; i <= n; ++i) {
    for (int j = 0; j <= m; ++j) dp[j] = dp1[j];
    for (int k = 0; k <= sz[i]; ++k)
      for (int j = m; j >= k; j--) dp[j] = max(dp[j], dp1[j - k] + mx[i][k]);
    for (int j = 0; j <= m; ++j) dp1[j] = dp[j];
  }
  cout << dp1[m];
}
