#include <bits/stdc++.h>
using namespace std;
const int MAXN = 3010;
int a[MAXN][MAXN], m[MAXN], n, k;
long long ans, sum[MAXN];
void Knapsack(vector<long long> &dp, int a, long long b) {
  for (int i = k; i >= a; i--) {
    dp[i] = max(dp[i], dp[i - a] + b);
  }
}
void DFS(int l, int r, const vector<long long> &f) {
  if (l == r) {
    ans = max(ans, f[k]);
    long long s = 0;
    for (int i = 1; i <= m[l] && i <= k; i++) {
      s += a[l][i];
      ans = max(ans, s + f[k - i]);
    }
    return;
  }
  vector<long long> g;
  int mid = (l + r) / 2;
  g = f;
  for (int i = mid + 1; i <= r; i++) {
    Knapsack(g, m[i], sum[i]);
  }
  DFS(l, mid, g);
  g = f;
  for (int i = l; i <= mid; i++) {
    Knapsack(g, m[i], sum[i]);
  }
  DFS(mid + 1, r, g);
}
int main() {
  ios::sync_with_stdio(false);
  cin >> n >> k;
  for (int i = 1; i <= n; i++) {
    cin >> m[i];
    for (int j = 1; j <= m[i]; j++) {
      cin >> a[i][j];
      sum[i] += a[i][j];
    }
  }
  DFS(1, n, vector<long long>(k + 1));
  cout << ans << endl;
  return 0;
}
