#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, cal, tt;
int dp[105][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]), cal += a[i][j];
    tt += a[i][0];
  }
  m = tt - m;
  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 j = 1; j <= a[i][0]; j++) s[i][j] = INF;
  for (int i = 0; i <= n; i++)
    for (int j = 1; j <= m; j++) dp[i][j] = INF;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= a[i][0]; j++)
      for (int k = 1; k <= j; k++)
        s[i][j - k + 1] = min(s[i][j - k + 1], sum[i][j] - sum[i][k - 1]);
}
void solve() {
  int tot = 0;
  for (int i = 1; i <= n; i++) {
    for (int cnt = 1; cnt <= m && cnt <= tot + a[i][0]; cnt++)
      dp[i][cnt] = dp[i - 1][cnt];
    for (int len = 1; len <= a[i][0]; len++)
      for (int cnt = len; cnt <= m && cnt <= tot + len; cnt++)
        dp[i][cnt] = min(dp[i][cnt], s[i][len] + dp[i - 1][cnt - len]);
    tot += a[i][0];
  }
  cout << cal - dp[n][m] << endl;
}
int main() {
  init();
  solve();
}
