#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2")
using namespace std;
int read() {
  int s = 0;
  char ch = getchar();
  while (isdigit(ch)) {
    s = s * 10 + ch - '0';
    ch = getchar();
  }
  return s;
}
long long dp[2][3010];
int main() {
  int n = read(), k = read();
  for (register int i = 1; i <= n; i++) {
    for (register int j = 0; j <= k; j++) dp[i & 1][j] = dp[(i - 1) & 1][j];
    int m = read();
    long long sum = 0;
    for (register int j = 1; j <= m; j++) {
      int tmp = read();
      sum += tmp;
      int x = i & 1;
      for (register int now = j; now <= k; now++)
        dp[x][now] = max(dp[x][now], dp[x ^ 1][now - j] + sum);
    }
  }
  cout << dp[n & 1][k] << endl;
}
