#include <bits/stdc++.h>
using namespace std;
const long long INF = 2000000000000000000LL;
const int inf = 0x3f3f3f3f;
const long double EPS = 1e-9;
const int N = 107;
const int M = 10000 + 7;
int dp[2][M];
int damage[N][N];
vector<int> shelf[N];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < n; ++i) {
    int p;
    cin >> p;
    shelf[i].resize(p);
    for (int j = 0; j < p; ++j) cin >> shelf[i][j];
  }
  memset(damage, 0, sizeof damage);
  for (int i = 0; i < n; ++i) {
    int tot = 0, sz = shelf[i].size();
    for (int &x : shelf[i]) tot += x;
    for (int j = 0; j <= sz; ++j) {
      int cnt = 0, sum = 0, best = inf;
      for (int k = 0; k < sz; ++k) {
        ++cnt;
        sum += shelf[i][k];
        if (cnt > j) --cnt, sum -= shelf[i][k - j];
        if (cnt == j) best = min(best, sum);
      }
      best = tot - best;
      damage[i][sz - j] = best;
    }
  }
  for (int i = n - 1; i >= 0; --i) {
    for (int j = 0; j <= m; ++j) {
      for (int k = 0; k <= (int)shelf[i].size() and k <= j; ++k) {
        dp[i & 1][j] = max(dp[i & 1][j], damage[i][k] + dp[(i + 1) & 1][j - k]);
      }
    }
  }
  cout << dp[0][m] << "\n";
  return 0;
}
