#include <bits/stdc++.h>
using namespace std;
int a[105], na;
int dp[10005];
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; i++) {
    scanf("%d", &na);
    for (int j = 0; j < na; j++) scanf("%d", &a[j]);
    int total = 0;
    for (int j = 0; j < na; j++) total += a[j];
    int v[105] = {};
    v[na] = total;
    for (int j = 0; j < na; j++) {
      for (int k = j, vs = 0; k < na; k++) {
        vs += a[k];
        v[na - (k - j + 1)] = max(v[na - (k - j + 1)], total - vs);
      }
    }
    for (int j = m; j >= 0; --j)
      for (int k = 1; k <= na && j - k >= 0; k++)
        dp[j] = max(dp[j], dp[j - k] + v[k]);
  }
  printf("%d\n", dp[m]);
  return 0;
}
