#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
const int maxn = 3003;
int pr[maxn][maxn];
int n, k;
vector<int> v[maxn];
long long sum[maxn];
int sz[maxn];
void read() {
  cin >> n >> k;
  for (int i = 1; i <= n; i++) {
    int curr_sz;
    cin >> curr_sz;
    sz[i] = curr_sz;
    v[i].resize(curr_sz);
    for (int j = 0; j < curr_sz; j++) cin >> v[i][j];
  }
}
void add_to_knapsack(long long *dp, int w, long long c) {
  for (int i = k; i >= w; i--) dp[i] = max(dp[i], dp[i - w] + c);
}
long long dp[maxn][maxn];
long long curr_dp[maxn];
void f(int l, int r) {
  if (l == r) {
    for (int i = 0; i <= k; i++) dp[l][i] = curr_dp[i];
    return;
  }
  long long prev_dp[maxn];
  for (int i = 0; i <= k; i++) prev_dp[i] = curr_dp[i];
  int mid = (l + r) / 2;
  for (int i = mid + 1; i <= r; i++) add_to_knapsack(curr_dp, sz[i], sum[i]);
  f(l, mid);
  for (int i = 0; i <= k; i++) curr_dp[i] = prev_dp[i];
  for (int i = l; i <= mid; i++) add_to_knapsack(curr_dp, sz[i], sum[i]);
  f(mid + 1, r);
}
void solve() {
  for (int i = 1; i <= n; i++)
    for (int j = 0; j < sz[i]; j++) sum[i] += v[i][j];
  f(1, n);
  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    ans = max(ans, dp[i][k]);
    long long curr_sum = 0;
    for (int j = 0; j < min(k, sz[i]); j++) {
      curr_sum += v[i][j];
      ans = max(ans, curr_sum + dp[i][k - j - 1]);
    }
  }
  cout << ans << '\n';
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  read();
  solve();
}
