#include <bits/stdc++.h>
using namespace std;
const int N = 100;
int n, m, sz[N], mx[N][N + 1], cum[N][N], dp[2][10001];
int main(int argc, char **argv) {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &sz[i]);
    for (int j = 0, x; j < sz[i]; ++j) {
      scanf("%d", &x);
      if (j != 0) cum[i][j] += cum[i][j - 1];
      cum[i][j] += x;
    }
  }
  for (int i = 0; i < n; ++i)
    for (int j = 1; j <= sz[i]; ++j)
      for (int k = 0; k <= j; ++k) {
        int res = 0;
        if (k != 0) res += cum[i][k - 1];
        if (j - k != 0)
          res += cum[i][sz[i] - 1] -
                 (j - k == sz[i] ? 0 : cum[i][sz[i] - (j - k) - 1]);
        mx[i][j] = max(mx[i][j], res);
      }
  int at = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j <= m; ++j)
      for (int k = 0; k <= min(j, sz[i]); ++k)
        dp[at][j] = max(dp[at][j], dp[at ^ 1][j - k] + mx[i][k]);
    at ^= 1;
  }
  printf("%d\n", dp[at ^ 1][m]);
  return 0;
}
