#include<bits/stdc++.h>
using namespace std;
using pii = pair<int, int>;
const int MAXN = 3001, INF = int(1e9);
int dp[MAXN], last[MAXN], k, ans, w[MAXN][MAXN];
struct Segment_Tree {
int l[MAXN << 2], r[MAXN << 2];
vector<pii> ve[MAXN << 2];
void build(int u, int s, int t) {
l[u] = s, r[u] = t;
if(s == t) {
return;
}
int mid = (s + t) >> 1;
build(u << 1, s, mid), build((u << 1) | 1, mid + 1, t);
}
void update(int u, int s, int t, pii x) {
if(s > t) {
return;
}
if(l[u] >= s && r[u] <= t) {
ve[u].push_back(x);
return;
}
if(s <= r[u << 1]) {
update(u << 1, s, t, x);
}
if(t >= l[(u << 1) | 1]) {
update((u << 1) | 1, s, t, x);
}
}
void DP(int u) {
for(int i = 0; i <= k; ++i) {
last[i] = dp[i];
}
for(auto [w, v] : ve[u]) {
for(int i = k; i >= w; --i) {
dp[i] = max(dp[i], dp[i - w] + v);
}
}
if(l[u] == r[u]) {
for(int i = 1; i <= min(p[i], k); ++i) {
ans = max(ans, dp[k - i] + w[l[u]][i]);
}
for(int i = 0; i <= k; ++i) {
dp[i] = last[i];
}
return;
}
DP(u << 1), DP((u << 1) | 1);
for(int i = 0; i <= k; ++i) {
dp[i] = last[i];
}
}
}tr;
int n, p[MAXN];
int main() {
ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
cin >> n >> k;
tr.build(1, 1, n);
for(int i = 1; i <= n; ++i) {
cin >> p[i];
for(int j = 1; j <= p[i]; ++j) {
cin >> w[i][j];
}
tr.update(1, 1, i - 1, {p[i], w[i][p[i]]});
tr.update(1, i + 1, n, {p[i], w[i][p[i]]});
}
fill(dp, dp + k + 1, -INF);
dp[0] = 0;
tr.DP(1);
cout << ans;
return 0;
}