#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
const long double PI = 3.141592653589793238462643383279502884197;
priority_queue<int, vector<int>, greater<int> > pq;
vector<int> v[100];
int ma[100][101];
int dp[100][10001];
int n, m;
int go(int o, int k) {
  if (o == n) return 0;
  if (dp[o][k] != -1) return dp[o][k];
  int mav = 0;
  for (int i = 0; i <= min(k, (int)(v[o]).size()); i++)
    mav = max(mav, ma[o][i] + go(o + 1, k - i));
  return dp[o][k] = mav;
}
int main() {
  memset(dp, -1, sizeof(dp));
  int sum;
  scanf("%d %d", &n, &m);
  for (int i = 0; i < n; i++) {
    int t, tt;
    scanf("%d", &t);
    for (int j = 0; j < t; j++) {
      scanf("%d", &tt);
      v[i].push_back(tt);
    }
    for (int j = 1; j <= t; j++) {
      sum = 0;
      for (int k = 0; k < j; k++) sum += v[i][k];
      ma[i][j] = max(ma[i][j], sum);
      tt = t - 1;
      for (int k = j - 1; k >= 0; k--) {
        sum -= v[i][k];
        sum += v[i][tt--];
        ma[i][j] = max(ma[i][j], sum);
      }
    }
  }
  printf("%d", go(0, m));
}
