#include <bits/stdc++.h>
using namespace std;
const int N = 3050;
const int inf = 0x3f3f3f3f;
const long long llinf = 0x3f3f3f3f3f3f3f3f;
const int mod = 998244353;
const int MOD = 1e9 + 7;
const double PI = acos(-1.0);
clock_t TIME__START, TIME__END;
void program_end() {}
int n, k;
struct Array {
  int size;
  long long sum;
  vector<int> x;
} a[N];
long long dp[35][N], ans;
void work(int l, int r, int step) {
  if (l == r) {
    ans = max(ans, dp[step][k]);
    long long now = 0;
    int sz = a[l].size;
    for (int i = 0; i < min(sz, k); ++i) {
      now += a[l].x[i];
      ans = max(ans, now + dp[step - 1][k - i - 1]);
    }
    return;
  }
  int mid = (l + r) >> 1;
  memcpy(dp[step], dp[step - 1], sizeof(dp[step - 1]));
  for (int i = l; i <= mid; ++i)
    for (int j = k - a[i].size; j >= 0; --j)
      dp[step][j + a[i].size] =
          max(dp[step][j + a[i].size], dp[step][j] + a[i].sum);
  work(mid + 1, r, step + 1);
  memcpy(dp[step], dp[step - 1], sizeof(dp[step - 1]));
  for (int i = mid + 1; i <= r; ++i)
    for (int j = k - a[i].size; j >= 0; --j)
      dp[step][j + a[i].size] =
          max(dp[step][j + a[i].size], dp[step][j] + a[i].sum);
  work(l, mid, step + 1);
}
inline void solve() {
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n; ++i) {
    int m;
    scanf("%d", &m);
    a[i].size = m;
    while (m--) {
      int num;
      scanf("%d", &num);
      a[i].x.push_back(num);
      a[i].sum += num;
    }
  }
  work(1, n, 1);
  cout << ans << '\n';
}
int main() {
  TIME__START = clock();
  int Test = 1;
  while (Test--) {
    solve();
  }
  TIME__END = clock();
  program_end();
  return 0;
}
