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