#include <bits/stdc++.h>
using namespace std;
const int MAXN = 110;
const int MAX = 10010;
int h[MAXN];
int t[MAXN][MAXN], s[MAXN][MAXN];
int dp[MAXN][MAXN][MAXN];
int d[MAXN][MAX];
int sum[MAXN];
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    cin >> h[i];
    sum[i] = sum[i - 1] + h[i];
    for (int j = 1; j <= h[i]; j++) {
      cin >> t[i][j];
      s[i][j] = s[i][j - 1] + t[i][j];
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= h[i]; j++) {
      for (int k = 1; k <= j; k++) {
        dp[i][j][k] = max(dp[i][j - 1][k - 1] + t[i][j], s[i][k]);
      }
    }
  }
  for (int j = 1; j <= h[1]; j++) {
    d[1][j] = dp[1][h[1]][j];
  }
  for (int i = 2; i <= n; i++) {
    for (int j = 1; j <= sum[i]; j++) {
      for (int k = 0; k <= min(h[i], j); k++) {
        d[i][j] = max(d[i][j], d[i - 1][j - k] + dp[i][h[i]][k]);
      }
    }
  }
  cout << d[n][m] << endl;
}
