#include <bits/stdc++.h>
using namespace std;
const int N = 150;
const int M = 10005;
int sz[N], n, m, f[N][N], a[N][N];
int k[N][N][N], dp[N][M];
void build(int id) {
  for (int i = 0; i < sz[id]; ++i) {
    k[i][i][1] = a[id][i];
    k[i][i][0] = 0;
    for (int j = i - 1; j > -1; --j) {
      k[j][i][0] = 0;
      for (int take = 1; take <= i - j + 1; ++take) {
        k[j][i][take] = max(a[id][j] + k[j + 1][i][take - 1],
                            a[id][i] + k[j][i - 1][take - 1]);
      }
    }
  }
  for (int i = 0; i <= sz[id]; ++i) {
    f[id][i] = k[0][sz[id] - 1][i];
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> m;
  for (int i = 1; i <= n; ++i) {
    cin >> sz[i];
    for (int j = 0; j < sz[i]; ++j) {
      cin >> a[i][j];
    }
    build(i);
    for (int j = 0; j <= m; ++j) {
      for (int take = 0; take <= min(sz[i], j); ++take) {
        dp[i][j] = max(dp[i][j], dp[i - 1][j - take] + f[i][take]);
      }
    }
  }
  cout << dp[n][m];
  return 0;
}
