#include <bits/stdc++.h>
using namespace std;
int n, k;
int dp1[101][10001];
vector<vector<int> > ar(101);
int go(int idx, int left) {
  if (idx == n) return 0;
  if (left == 0) return 0;
  if (dp1[idx][left] != -1) return dp1[idx][left];
  int ans = 0;
  for (int i = 0; i < ar[idx].size(); i++) {
    if (left - i < 0) break;
    ans = max(ans, ar[idx][i] + go(idx + 1, left - i));
  }
  return dp1[idx][left] = ans;
}
int dp[101][101];
void find(int l, int r, int cur_sum, int idx, vector<int> &v,
          vector<int> &sum) {
  sum[idx] = max(sum[idx], cur_sum);
  if (l > r) return;
  if (dp[l][r] != -1) return;
  find(l + 1, r, cur_sum + v[l], idx + 1, v, sum);
  find(l, r - 1, cur_sum + v[r], idx + 1, v, sum);
  dp[l][r] = 1;
}
vector<int> Max(vector<int> v) {
  memset(dp, -1, sizeof(dp));
  vector<int> sum((int)v.size() + 1, -1);
  find(0, (int)v.size() - 1, 0, 0, v, sum);
  return sum;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  memset(dp1, -1, sizeof(dp1));
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    int b;
    cin >> b;
    while (b--) {
      int num;
      cin >> num;
      ar[i].push_back(num);
    }
  }
  for (int i = 0; i < n; i++) {
    ar[i] = Max(ar[i]);
  }
  cout << go(0, k);
}
