#include <bits/stdc++.h>
int a[120], dp[10010], dpn[10010];
int max(int a, int b) { return a > b ? a : b; }
int main() {
  int n, ans = 0, b;
  scanf("%d%d", &n, &b);
  for (int i = 0; i < n; i++) {
    memset(a, 0, sizeof a);
    memset(dp, 0, sizeof dp);
    int num;
    scanf("%d", &num);
    for (int j = 1; j <= num; j++) scanf("%d", &a[j]);
    int temp1 = 0;
    for (int j = 0; j <= num; j++) {
      int temp2 = 0;
      temp1 += a[j];
      for (int k = 0; k <= num - j; k++) {
        temp2 += a[num - k + 1];
        dp[j + k] = max(dp[j + k], temp1 + temp2);
      }
    }
    for (int j = b; j > 0; j--) {
      for (int k = 0; k <= num && k <= j; k++) {
        dpn[j] = max(dpn[j], dpn[j - k] + dp[k]);
        ans = max(ans, dpn[j]);
      }
    }
  }
  printf("%d", ans);
  return 0;
}
