#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
int n, k;
int vec[3000][3000];
long long sum[3000];
int len[3000];
vector<long long> dp;
long long dnc(int l, int r) {
  long long ret = 0;
  if (l == r) {
    long long ss = 0;
    for (int i = 0; i < len[l]; i++) {
      ss += vec[l][i];
      ret = max(ret, dp[k - i - 1] + ss);
    }
    return ret;
  }
  int mid = (l + r) / 2;
  vector<long long> dd = dp;
  for (int i = mid + 1; i <= r; i++)
    for (int j = k; j >= len[i]; j--)
      dp[j] = max(dp[j], dp[j - len[i]] + sum[i]);
  ret = max(ret, dnc(l, mid));
  dp = dd;
  for (int i = l; i <= mid; i++)
    for (int j = k; j >= len[i]; j--)
      dp[j] = max(dp[j], dp[j - len[i]] + sum[i]);
  ret = max(ret, dnc(mid + 1, r));
  return ret;
}
int main() {
  scanf("%d %d", &n, &k);
  for (int i = 0; i < n; i++) {
    int tt, t;
    scanf("%d", &t);
    tt = t;
    if (t > k) t = k;
    len[i] = t;
    for (int j = 0; j < t; j++) scanf("%d", &vec[i][j]), sum[i] += vec[i][j];
    for (int j = t; j < tt; j++) scanf("%*d");
  }
  dp.resize(k + 1);
  printf("%lld", dnc(0, n - 1));
}
