#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e4 + 100;
const int INF = 0x3f3f3f3f;
int cost[110][110], val[110][110];
int num[110];
int a[110];
long long dp[110][110][110];
int m;
void get(int cnt) {
  scanf("%d", &num[cnt]);
  int n = num[cnt];
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &a[i]);
  }
  memset(dp, 0, sizeof dp);
  for (int k = 1; k <= 100; ++k) {
    for (int i = 1; i <= n; ++i) {
      dp[k][1][i] = max(dp[k][1][i], (long long)1);
    }
    for (int i = 1; i <= n; ++i) {
      for (int j = 1; j + i - 1 <= n; ++j) {
        dp[k][i][j] = max(dp[k - 1][i - 1][j] + a[i + j - 1],
                          dp[k - 1][i - 1][j + 1] + a[j]);
      }
    }
  }
  for (int i = 1; i <= 100; ++i) {
    val[cnt][i] = dp[i][n][1];
  }
}
long long d[2][maxn];
int main() {
  int n;
  while (cin >> n >> m) {
    for (int i = 1; i <= n; ++i) {
      get(i);
    }
    int now = 1, pre = 0;
    memset(dp, 0, sizeof d);
    memset(dp[now], 0, sizeof dp[now]);
    for (int i = 1; i <= n; ++i) {
      swap(now, pre);
      memset(dp[now], 0, sizeof dp[now]);
      for (int j = 0; j <= m; ++j) {
        for (int k = 0; k <= num[i]; ++k) {
          if (k <= j) d[now][j] = max(d[now][j], d[pre][j - k] + val[i][k]);
        }
      }
    }
    long long ans = 0;
    for (int i = 0; i <= m; ++i) {
      ans = max(ans, d[now][i]);
    }
    cout << d[now][m] << "\n";
  }
  return 0;
}
