#include <bits/stdc++.h>
const int maxn = 100 + 10;
int f[maxn][maxn], N, M, arr[maxn][maxn], tmp[maxn][maxn][maxn];
int dp[100000 + 10];
void Dp(int row) {
  memset(tmp, 0, sizeof(tmp));
  for (int i = 1; i <= arr[row][0]; ++i) {
    tmp[i][i][1] = arr[row][i];
  }
  for (register int len = 2; len <= arr[row][0]; ++len) {
    for (register int s = 1; s <= arr[row][0]; ++s) {
      int e = s + len - 1;
      for (register int k = 1; k <= len; ++k) {
        tmp[s][e][k] = (((tmp[s][e - 1][k - 1] + arr[row][e]) >
                         (tmp[s + 1][e][k - 1] + arr[row][s]))
                            ? (tmp[s][e - 1][k - 1] + arr[row][e])
                            : (tmp[s + 1][e][k - 1] + arr[row][s]));
      }
    }
  }
  for (int i = 1; i <= arr[row][0]; ++i) {
    f[row][i] = tmp[1][arr[row][0]][i];
  }
}
inline long long read() {
  long long f = 1, r = 0;
  char c = getchar();
  while (!isdigit(c)) {
    if (c == '-') {
      f = -1;
    }
    c = getchar();
  }
  while (isdigit(c)) {
    r = 10 * r + c - '0';
    c = getchar();
  }
  return f * r;
}
inline void write(long long x) {
  if (x < 0) putchar('-'), x = -x;
  if (x > 9) write(x / 10);
  putchar(x % 10 + '0');
}
inline void writesp(long long x) { write(x), putchar(' '); }
inline void writeln(long long x) { write(x), puts(""); }
int main() {
  N = read(), M = read();
  for (int i = 1; i <= N; ++i) {
    arr[i][0] = read();
    for (int j = 1; j <= arr[i][0]; ++j) {
      arr[i][j] = read();
    }
    Dp(i);
  }
  for (int i = 1; i <= N; ++i) {
    for (int j = M; j >= 0; j--) {
      for (int k = (((j) < (arr[i][0])) ? (j) : (arr[i][0])); k >= 1; k--) {
        dp[j] = (((dp[j - k] + f[i][k]) > (dp[j])) ? (dp[j - k] + f[i][k])
                                                   : (dp[j]));
      }
    }
  }
  writeln(dp[M]);
  return 0;
}
