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