#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const long long maxn = 2e5 + 5;
long long rowdp[101][101];
vector<long long> a[101];
void f(long long id) {
  vector<long long> dp(101, 0);
  for (long long i = 0; i < a[id].size(); ++i) {
    if (i == 0)
      dp[i] = a[id][i];
    else
      dp[i] = dp[i - 1] + a[id][i];
  }
  long long tot = rowdp[id][a[id].size()] = dp[a[id].size() - 1];
  for (long long l = 1; l <= a[id].size(); ++l) {
    for (long long i = 0; i + l - 1 < a[id].size(); ++i) {
      long long curr = 0;
      if (i) curr = dp[i - 1];
      rowdp[id][a[id].size() - l] =
          max(rowdp[id][a[id].size() - l], tot - (dp[i + l - 1] - curr));
    }
  }
}
long long dp[101][10001];
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long n, m;
  cin >> n >> m;
  for (long long i = 0; i < n; ++i) {
    long long x;
    cin >> x;
    while (x--) {
      long long y;
      cin >> y;
      a[i].emplace_back(y);
    }
    f(i);
  }
  long long tot = 0;
  for (long long i = 0; i < n; ++i) {
    if (i) {
      for (long long j = 0; j <= min(m, tot); ++j) {
        for (long long k = 0; k <= a[i].size(); ++k) {
          if (j + k > m) continue;
          dp[i][j + k] = max(dp[i][j + k], dp[i - 1][j] + rowdp[i][k]);
        }
      }
    } else {
      for (long long j = 1; j <= a[0].size(); ++j) {
        dp[0][j] = rowdp[0][j];
      }
    }
    tot += a[i].size();
  }
  cout << dp[n - 1][m] << '\n';
  ;
  return 0;
}
