#include <bits/stdc++.h>
int n, m, b[107][107], f[107][107], dp[10007];
inline int max(int a, int b) { return a > b ? a : b; }
inline int min(int a, int b) { return a > b ? b : a; }
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &b[i][0]);
    for (int j = 1; j <= b[i][0]; ++j) scanf("%d", &b[i][j]);
    for (int j = 1; j <= b[i][0]; ++j) {
      for (int k = 0; k <= j; ++k) {
        int ans = 0;
        for (int a = 1; a <= k; ++a) ans += b[i][a];
        for (int a = 0; a < j - k; ++a) ans += b[i][b[i][0] - a];
        f[i][j] = max(f[i][j], ans);
      }
    }
  }
  for (int i = 1; i <= n; ++i)
    for (int j = m; j >= 1; --j)
      for (int k = 1; k <= min(j, b[i][0]); ++k)
        dp[j] = max(dp[j], dp[j - k] + f[i][k]);
  printf("%d", dp[m]);
  return 0;
}
