#include <bits/stdc++.h>
using namespace std;
vector<long long> val[105];
long long maxVal[105][105], dp[105][105 * 105], cumsum[105][105];
bool vis[105][105 * 105];
long long n, m;
long long maxAnsDP(long long idx, long long take) {
  if (take <= 0) return 0;
  if (idx > n) return (-1 * 100000);
  if (vis[idx][take]) return dp[idx][take];
  vis[idx][take] = true;
  for (long long i = 0; i <= min(take, (long long)val[idx].size()); i++)
    dp[idx][take] =
        max(dp[idx][take], maxVal[idx][i] + maxAnsDP(idx + 1, take - i));
  return dp[idx][take];
}
int main() {
  long long t, i, j, k, a, b, c, cs = 1;
  cin >> n >> m;
  for (i = 1; i <= n; i++) {
    cin >> t;
    while (t--) {
      cin >> a;
      val[i].push_back(a);
    }
  }
  for (i = 1; i <= n; i++)
    for (j = 0; j < (long long)val[i].size(); j++)
      cumsum[i][j + 1] = cumsum[i][j] + val[i][j];
  for (i = 1; i <= n; i++) {
    for (j = 0; j <= (long long)val[i].size(); j++) {
      for (k = 0; k <= j; k++) {
        long long total = cumsum[i][k] - cumsum[i][0];
        a = j - k;
        total += cumsum[i][val[i].size()] - cumsum[i][val[i].size() - a];
        maxVal[i][j] = max(maxVal[i][j], total);
      }
    }
  }
  cout << maxAnsDP(1, m);
  return 0;
}
