#include <bits/stdc++.h>
using namespace std;
long long n, m, tot[110], f[110][110], a[110][110], sum1[110], sum2[110],
    dp[100010];
int main() {
  scanf("%lld%lld", &n, &m);
  for (int i = 1; i <= n; i++) {
    scanf("%lld", &tot[i]);
    for (int j = 1; j <= tot[i]; j++) scanf("%lld", &a[i][j]);
    for (int j = 1; j <= tot[i]; j++) sum1[j] = sum1[j - 1] + a[i][j];
    for (int j = 1; j <= tot[i]; j++)
      sum2[j] = sum2[j - 1] + a[i][tot[i] - j + 1];
    for (int j = 1; j <= tot[i]; j++)
      for (int k = 0; k <= j; k++)
        f[i][j] = max(f[i][j], sum1[k] + sum2[j - k]);
  }
  for (int i = 1; i <= n; i++)
    for (int j = m; j >= 1; j--)
      for (int k = 0; k <= j && k <= tot[i]; k++)
        dp[j] = max(dp[j], dp[j - k] + f[i][k]);
  printf("%lld\n", dp[m]);
}
