#include <bits/stdc++.h>
const long long inf = 0x3f3f3f3f3f3f3f3LL;
const long long mod = (long long)1e9 + 7;
using namespace std;
template <class T, class T2>
void smin(T& a, T2 val) {
  if (a > val) a = val;
}
template <class T, class T2>
void smax(T& a, T2 val) {
  if (a < val) a = val;
}
const long long N = 555;
long long n, m;
vector<vector<long long>> A;
long long mx[N][N], pref[N][N];
long long dp[101][10001];
long long solve(long long idx, long long cnt) {
  if (cnt > m) {
    return -inf;
  }
  if (idx == n) {
    return (cnt == m) ? 0 : -inf;
  }
  long long& ans = dp[idx][cnt];
  if (ans != -1) {
    return ans;
  }
  ans = 0;
  long long sz = (long long)(A[idx].size());
  for (long long taken = 0; taken <= sz; ++taken) {
    smax(ans, mx[idx][taken] + solve(idx + 1, cnt + taken));
  }
  return ans;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> n >> m;
  for (long long i = 0; i < n; ++i) {
    long long x;
    cin >> x;
    vector<long long> v;
    for (long long j = 0; j < x; ++j) {
      long long y;
      cin >> y;
      v.push_back(y);
    }
    A.push_back(v);
  }
  for (long long i = 0; i < n; ++i) {
    for (long long j = 0; j < (long long)(A[i].size()); ++j) {
      pref[i][j + 1] = pref[i][j];
      pref[i][j + 1] += A[i][j];
    }
  }
  for (long long i = 0; i < n; ++i) {
    long long sz = (long long)(A[i].size());
    for (long long taken = 0; taken <= sz; ++taken) {
      long long maximum = 0;
      for (long long left = 0; left <= taken; ++left) {
        long long right = taken - left;
        long long left_sum = pref[i][left];
        long long right_sum =
            pref[i][sz] - ((sz - right < 0) ? 0 : pref[i][sz - right]);
        smax(maximum, left_sum + right_sum);
      }
      mx[i][taken] = maximum;
    }
  }
  memset(dp, -1, sizeof dp);
  cout << solve(0, 0);
  return 0;
}
