#include <bits/stdc++.h>
using namespace std;
int n, m, k[108], a[105], mx[105][105], sum[106], sump[106];
long long memo[105][10005];
long long dp(int i, int m) {
  if (m <= 0) return 0;
  if (i > n) return 0;
  if (memo[i][m] != -1) return memo[i][m];
  long long ret = 0;
  for (int j = 0; j <= min(k[i], m); j++) {
    ret = max(ret, mx[i][j] + dp(i + 1, m - j));
  }
  return memo[i][m] = ret;
}
int main() {
  cin >> n >> m;
  memset(memo, -1, sizeof(memo));
  for (int i = 1; i <= n; i++) {
    cin >> k[i];
    for (int j = 1; j <= k[i]; j++) {
      cin >> a[j];
    }
    sum[1] = a[1];
    sump[1] = a[k[i]];
    for (int j = 2; j <= k[i]; j++) {
      sum[j] = sum[j - 1] + a[j];
      sump[j] = sump[j - 1] + a[k[i] - (j - 1)];
    }
    for (int j = 1; j <= k[i]; j++)
      for (int l = 0; l <= j; l++) {
        mx[i][j] = max(mx[i][j], sum[j - l] + sump[l]);
      }
  }
  cout << dp(1, m);
  return 0;
}
