#include <bits/stdc++.h>
using namespace std;
int a[105][105], l[105][105], r[105][105];
int f[105][105], dp[10005];
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i][0]);
    l[i][0] = 0;
    for (int j = 1; j <= a[i][0]; j++) {
      scanf("%d", &a[i][j]);
      l[i][j] += l[i][j - 1] + a[i][j];
    }
    r[i][a[i][0] + 1] = 0;
    for (int j = a[i][0]; j >= 1; j--) r[i][j] += r[i][j + 1] + a[i][j];
    for (int j = 0; j <= a[i][0]; j++)
      for (int k = 0; k <= j; k++)
        f[i][j] = max(f[i][j], l[i][k] + r[i][a[i][0] - (j - k) + 1]);
  }
  for (int i = 1; i <= n; i++)
    for (int j = m; j >= 0; j--)
      for (int k = 0; k <= a[i][0] && k <= j; k++)
        dp[j] = max(dp[j], dp[j - k] + f[i][k]);
  printf("%d\n", dp[m]);
  return 0;
}
