#include <bits/stdc++.h>
using namespace std;
const double eps = 0.000000000000001;
int sz[110] = {0}, n, m;
int val[110][110] = {0};
int nx[110] = {0};
long long sm[110] = {0};
long long dp[110][10010];
long long mxit[110][110] = {0};
long long doit(int c, int m) {
  if (c > n) {
    if (m == 0)
      return 0;
    else
      return INT_MIN;
  }
  int atl = m - nx[c + 1], i, j;
  if (atl > sz[c]) return INT_MIN;
  if (dp[c][m] != -1) return dp[c][m];
  atl = max(atl, 0);
  int atm = min(sz[c], m);
  long long ret = 0;
  for (i = atl; i <= atm; i++) {
    ret = max(ret, mxit[c][i] + doit(c + 1, m - i));
  }
  return dp[c][m] = ret;
}
int main() {
  scanf("%d%d", &n, &m);
  int i, j;
  for (i = 1; i <= n; i++) {
    scanf("%d", &sz[i]);
    long long s = 0;
    for (j = 1; j <= sz[i]; j++) {
      scanf("%d", &val[i][j]);
      s += val[i][j];
      val[i][j] += val[i][j - 1];
    }
    sm[i] = s;
  }
  for (i = n; i >= 1; i--) {
    nx[i] = nx[i + 1] + sz[i];
  }
  for (i = 0; i <= n; i++)
    for (j = 0; j <= m; j++) dp[i][j] = -1;
  for (i = 1; i <= n; i++) {
    mxit[i][0] = 0;
    for (j = 1; j <= sz[i]; j++) {
      int lo = sz[i] - j, z;
      for (z = 1; z <= sz[i] - lo + 1; z++) {
        mxit[i][j] = max(mxit[i][j], sm[i] - ((long long)val[i][z + lo - 1] -
                                              val[i][z - 1]));
      }
    }
  }
  long long ans = doit(1, m);
  printf("%lld\n", ans);
  return 0;
}
