#include <bits/stdc++.h>
using namespace std;
const int N = 100 + 10;
const int inf = 1e9;
int val[N][N], items[N], dp[N][N * N];
int shelves, lft[N][N], rt[N][N];
int mx[N][N], k;
void CalMax() {
  for (int i = 1; i <= shelves; i++) {
    for (int j = 0; j <= items[i]; j++) {
      mx[i][j] = 0;
      lft[i][j] = 0;
      rt[i][j] = 0;
    }
  }
  for (int i = 1; i <= shelves; i++) {
    lft[i][0] = 0;
    for (int j = 1; j <= items[i]; j++) {
      lft[i][j] = lft[i][j - 1] + val[i][j];
    }
    rt[i][0] = 0;
    int tmp = 0;
    for (int j = items[i]; j >= 1; j--) {
      rt[i][++tmp] = rt[i][tmp - 1] + val[i][j];
    }
  }
  for (int i = 1; i <= shelves; i++) {
    for (int j = 1; j <= items[i]; j++) {
      for (int itr = 0; itr <= j; itr++) {
        mx[i][j] = max(mx[i][j], lft[i][itr] + rt[i][j - itr]);
      }
    }
  }
}
int rec(int pos, int rem) {
  if (pos > shelves) {
    return (rem == 0 ? 0 : -inf);
  }
  if (rem == 0) return 0;
  int &ret = dp[pos][rem];
  if (ret != -1) return ret;
  ret = 0;
  for (int i = 0; i <= items[pos]; i++) {
    if (i > rem) break;
    ret = max(ret, mx[pos][i] + rec(pos + 1, rem - i));
  }
  return ret;
}
int main() {
  scanf("%d %d", &shelves, &k);
  for (int i = 1; i <= shelves; i++) {
    scanf("%d", &items[i]);
    for (int j = 1; j <= items[i]; j++) {
      scanf("%d", &val[i][j]);
    }
  }
  memset(dp, -1, sizeof(dp));
  CalMax();
  int ans = rec(1, k);
  printf("%d\n", ans);
  return 0;
}
