#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  int dp[n][101];
  memset(dp, -1, sizeof dp);
  int s[101];
  int len;
  int sm;
  int acum;
  int aux;
  for (int k = 0; k < int(n); k++) {
    scanf("%d", &len);
    sm = 0;
    for (int i = 0; i < int(len); i++) {
      scanf("%d", &s[i]);
      sm += s[i];
    }
    for (int i = 0; i < int(len); i++) {
      acum = 0;
      for (int j = int(i); j < int(len); j++) {
        acum += s[j];
        aux = len - (j - i + 1);
        dp[k][aux] = max(dp[k][aux], sm - acum);
      }
    }
    dp[k][len] = sm;
  }
  int dp1[2][m + 1];
  memset(dp1, -1, sizeof dp1);
  dp1[1][0] = 0;
  dp1[0][0] = 0;
  int now = 0;
  int last = 1;
  for (int i = 0; i < int(n); i++) {
    for (int j = int(1); j < int(101); j++) {
      if (dp[i][j] == -1) break;
      for (int k = 0; k < int(m + 1); k++) {
        if (j + k >= m + 1 || dp1[last][k] == -1) break;
        dp1[now][j + k] = max(dp1[last][j + k],
                              max(dp1[now][j + k], dp[i][j] + dp1[last][k]));
      }
    }
    last = (last + 1) % 2;
    now = (now + 1) % 2;
  }
  printf("%d", dp1[last][m]);
  return 0;
}
