#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  long long x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
long long k[110];
long long val[110][110];
long long f[10010][2];
long long v[110], suml[110], sumr[110];
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= n; ++i) {
    k[i] = read();
    suml[0] = 0;
    for (int j = 1; j <= k[i]; ++j) {
      v[j] = read();
      suml[j] = suml[j - 1] + v[j];
    }
    sumr[k[i] + 1] = 0;
    for (int j = k[i]; j >= 1; --j) {
      sumr[j] = sumr[j + 1] + v[j];
    }
    for (int j = 1; j <= k[i]; ++j) {
      for (int d = 0; d <= j; ++d) {
        val[i][j] = max(val[i][j], suml[d] + sumr[k[i] - (j - d) + 1]);
      }
    }
  }
  long long ans = 0;
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= k[i]; ++j) {
      for (int w = m; w >= j; --w) {
        f[w][i & 1] = max(f[w][i & 1], f[w - j][(i + 1) & 1] + val[i][j]);
        ans = max(ans, f[w][i & 1]);
      }
    }
    for (int j = 1; j <= m; ++j) {
      f[j][i & 1] = max(f[j][i & 1], f[j][(i + 1) & 1]);
      f[j][(i + 1) & 1] = 0;
    }
  }
  cout << ans << endl;
}
