#include <bits/stdc++.h>
using namespace std;
const int MAXK = 3000;
struct Update {
  int cost;
  long long profit;
};
struct CommutativeUndoableDS {
  vector<array<long long, MAXK + 1> > dp;
  CommutativeUndoableDS() {
    dp.emplace_back();
    fill(dp.back().begin(), dp.back().end(), 0);
  }
  void addUpdate(Update u) {
    int sz = dp.size();
    dp.push_back(dp.back());
    for (int i = MAXK; i >= u.cost; i--) {
      dp[sz][i] = max(dp[sz][i], dp[sz - 1][i - u.cost] + u.profit);
    }
  }
  void undoLastUpdate() {
    dp.pop_back();
    assert(!dp.empty());
  }
  long long operator[](int i) { return dp.back()[i]; }
};
struct QueueUndoDS {
  vector<pair<Update, int> > qyu;
  CommutativeUndoableDS ds;
  int rem_a;
  QueueUndoDS() { rem_a = 0; }
  void pushBack(pair<Update, int> u) {
    ds.addUpdate(u.first);
    qyu.emplace_back(u);
  }
  void pushBack(Update u) { pushBack(pair<Update, int>(u, 1)); }
  void popFront() {
    assert(!qyu.empty());
    if (rem_a == 0) {
      rem_a = qyu.size();
      for (int i = 0; i < rem_a; i++) ds.undoLastUpdate();
      reverse(qyu.begin(), qyu.end());
      for (pair<Update, int> &u : qyu) {
        u.second = 0;
        ds.addUpdate(u.first);
      }
    }
    vector<pair<Update, int> > popped[2];
    while (qyu.back().second == 1) {
      popped[1].push_back(qyu.back());
      qyu.pop_back();
      ds.undoLastUpdate();
    }
    int sz = rem_a & (-rem_a);
    for (int i = 0; i < sz; i++) {
      assert(qyu.back().second == 0);
      popped[0].push_back(qyu.back());
      qyu.pop_back();
      ds.undoLastUpdate();
    }
    for (int z : {1, 0}) {
      reverse(popped[z].begin(), popped[z].end());
      for (pair<Update, int> &u : popped[z]) pushBack(u);
    }
    assert(qyu.back().second == 0);
    ds.undoLastUpdate();
    qyu.pop_back();
    rem_a--;
  }
};
vector<long long> a[MAXK];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  QueueUndoDS qds;
  for (int i = 1; i <= n; i++) {
    int sz;
    cin >> sz;
    a[i].resize(sz + 1);
    for (int j = 1; j <= sz; j++) {
      cin >> a[i][j];
      a[i][j] += a[i][j - 1];
    }
    if (sz > k) a[i].resize(k + 1);
    qds.pushBack({(int)a[i].size() - 1, a[i].back()});
  }
  long long ans = -1;
  for (int i = 1; i <= n; i++) {
    qds.popFront();
    for (int j = 0; j < a[i].size(); j++) {
      ans = max(ans, a[i][j] + qds.ds[k - j]);
    }
    qds.pushBack({(int)a[i].size() - 1, a[i].back()});
  }
  cout << ans << "\n";
  return 0;
}
