#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e3 + 5;
int dp[100005], a[maxn][maxn], n, m, num[maxn], v[maxn][maxn], ans;
int main() {
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    cin >> num[i];
    for (int j = 1; j <= num[i]; j++) {
      cin >> a[i][j];
      a[i][j] += a[i][j - 1];
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= num[i]; j++) {
      for (int k = 0; k <= j; k++) {
        v[i][j] = max(v[i][j], a[i][k] + a[i][num[i]] - a[i][num[i] - j + k]);
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = m; j >= 0; j--) {
      for (int k = 0; k <= num[i]; k++) {
        if (j >= k) dp[j] = max(dp[j], dp[j - k] + v[i][k]);
        ans = max(ans, dp[j]);
      }
    }
  }
  cout << ans << endl;
}
