#include <bits/stdc++.h>
using namespace std;
int const lim = 100 + 3;
int const lim1 = 1e4 + 3;
int dp[2][lim1][lim + 3], dp2[2][lim1 + 2][lim + 3];
int inp[lim + 3][lim + 3], pre[lim + 3][lim + 3], suf[lim + 3][lim + 3],
    siz[lim + 3], tem[lim1 + 3];
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &siz[i]);
    for (int j = 1; j <= siz[i]; j++)
      scanf("%d", &inp[i][j]), pre[i][j] = pre[i][j - 1] + inp[i][j];
    for (int j = siz[i]; j >= 1; j--) suf[i][j] = suf[i][j + 1] + inp[i][j];
  }
  bool b = true;
  for (int i = 1; i <= n; i++) {
    b ^= 1;
    int sz = siz[i];
    for (int j = 0; j <= m; j++) {
      dp[b][j][0] = dp[!b][j][siz[i - 1]];
      for (int k = 1; k <= siz[i]; k++)
        if (j - k >= 0)
          dp[b][j][k] =
              max(dp[b][j][k - 1], dp[!b][j - k][siz[i - 1]] + pre[i][k]);
        else
          dp[b][j][k] = max(dp[b][j][k], dp[b][j][k - 1]);
    }
    for (int j = 0; j <= m; j++) {
      for (int k = sz; k >= 1; k--)
        if (j - (sz - k + 1) >= 0)
          dp2[b][j][k] =
              max(dp[b][j][k], dp[b][j - (sz - k + 1)][k - 1] + suf[i][k]);
    }
    for (int j = 0; j <= m; j++)
      for (int k = 1; k <= siz[i]; k++)
        dp[b][j][k] = max(dp[b][j][k], max(dp2[b][j][k], dp[b][j][k - 1]));
  }
  cout << dp[b][m][siz[n]] << endl;
}
