#include <bits/stdc++.h>
using namespace std;
int dp[105][10005], cost[105][105], sz[105];
int sum[105], pre[105];
void input() {
  int i, j, k, n, nm, x;
  scanf("%d %d", &n, &nm);
  for ((i) = (1); (i) <= (n); (i)++) {
    scanf("%d", &sz[i]);
    sum[i] = sum[i - 1] + sz[i];
    for ((j) = (1); (j) <= (sz[i]); (j)++)
      scanf("%d", &x), pre[j] = pre[j - 1] + x;
    for ((j) = (1); (j) <= (sz[i]); (j)++)
      for ((k) = (0); (k) <= (j); (k)++)
        cost[i][j] =
            ((cost[i][j]) > (pre[k] + pre[sz[i]] - pre[sz[i] - (j - k)])
                 ? (cost[i][j])
                 : (pre[k] + pre[sz[i]] - pre[sz[i] - (j - k)]));
  }
  for ((i) = (1); (i) <= (n); (i)++)
    for ((j) = (0); (j) <= (sum[i]); (j)++)
      for ((k) = (0); (k) <= (sz[i]); (k)++)
        if (j >= k)
          dp[i][j] = ((dp[i][j]) > (dp[i - 1][j - k] + cost[i][k])
                          ? (dp[i][j])
                          : (dp[i - 1][j - k] + cost[i][k]));
        else
          break;
  printf("%d\n", dp[n][nm]);
}
int main() {
  input();
  return 0;
}
