#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma")
#pragma GCC optimize("unroll-loops")
using namespace std;
int n, k, t, a, b;
long long w, z, x[3008], y[3008];
int main() {
  for (ios::sync_with_stdio(0), cin.tie(0), cin >> n >> k; n--; z = b = 0) {
    for (cin >> t; t--;)
      for (cin >> a, z += a, ++b, a = k + 1; a-- > b;
           y[a] < (w = x[a - b] + z) ? y[a] = w : 0)
        ;
    for (a = k + 1; a--; x[a] = y[a])
      ;
  }
  cout << x[k], exit(0);
}
