#include <bits/stdc++.h>
using namespace std;
int M[105][105];
int n, m;
int c[105];
int sum[105];
void init(int r, int countt) {
  for (int i = 1; i <= countt; i++) {
    sum[i] = sum[i - 1] + M[r][i];
  }
  for (int i = 1; i <= countt; i++) {
    for (int j = 0; j <= i; j++) {
      int k = i - j;
      M[r][i] = max(M[r][i], sum[j] + sum[countt] - sum[countt - k]);
    }
  }
}
int dp[10005];
int main() {
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    cin >> c[i];
    for (int j = 1; j <= c[i]; j++) scanf("%d", &M[i][j]);
    init(i, c[i]);
  }
  for (int i = 1; i <= n; i++) {
    for (int j = m; j >= 0; j--) {
      for (int k = 1; k <= c[i]; k++) {
        if (k > j) break;
        dp[j] = max(dp[j], dp[j - k] + M[i][k]);
      }
    }
  }
  cout << dp[m];
}
