#include <bits/stdc++.h>
using namespace std;
int s1[110], s2[110], dp[110][110], sdp[110][100010], sz[110], n, m;
vector<int> shelf[110];
inline int solve(int i, int j) {
  int ans = max(s1[j], s2[i - j + 1]);
  for (int x = 1; x < j; x++) {
    ans = max(ans, s1[x] + s2[i - (j - x) + 1]);
  }
  return ans;
}
inline int solve1(int i, int j) {
  if (j <= 0) return 0;
  if (i == n + 1) return 0;
  int &ret = sdp[i][j];
  if (ret != -1) return ret;
  for (int x = 0; x <= j && x <= sz[i]; x++)
    ret = max(ret, solve1(i + 1, j - x) + dp[i][x]);
  return ret;
}
int main() {
  scanf("%d", &n);
  ;
  scanf("%d", &m);
  ;
  for (int x = 1; x <= n; x++) {
    scanf("%d", &sz[x]);
    ;
    shelf[x].emplace_back(0);
    for (int y = 1; y <= sz[x]; y++) {
      int p;
      scanf("%d", &p);
      ;
      shelf[x].emplace_back(p);
    }
    for (int y = 0; y <= 100; y++) s1[y] = s2[y] = 0;
    for (int y = 1; y <= sz[x]; y++) {
      s1[y] = s1[y - 1] + shelf[x][y];
      s2[sz[x] - y + 1] = s2[sz[x] - y + 2] + shelf[x][sz[x] - y + 1];
    }
    for (int y = 1; y <= sz[x]; y++) {
      dp[x][0] = 0;
      dp[x][y] = solve(sz[x], y);
    }
  }
  memset(sdp, -1, sizeof(sdp));
  ;
  printf("%d", solve1(1, m));
}
