#include <bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[]) {
  int n, m, k;
  cin >> n >> m >> k;
  vector<vector<vector<int>>> mp;
  for (int i = 0; i < n; i++) {
    vector<vector<int>> v;
    string s;
    cin >> s;
    for (int j = 0; j < m; j++) {
      std::vector<int> v1;
      int a, b, c;
      cin >> a >> b >> c;
      v1.push_back(a);
      v1.push_back(b);
      v1.push_back(c);
      v.push_back(v1);
    }
    mp.push_back(v);
  }
  int max_profit = 0;
  for (int i1 = 0; i1 < n; i1++) {
    for (int i2 = 0; i2 < n; i2++) {
      if (i2 == i1) continue;
      vector<vector<int>> v1;
      vector<vector<int>> v2;
      v1 = mp[i1];
      v2 = mp[i2];
      vector<pair<int, int>> vp;
      for (int j = 0; j < m; j++) {
        pair<int, int> p;
        p = {v2[j][1] - v1[j][0], v1[j][2]};
        vp.push_back(p);
      }
      sort(vp.begin(), vp.end());
      int temp = k;
      int profit = 0;
      for (int j = m - 1; j >= 0; j--) {
        if (temp < 0 || vp[j].first <= 0) break;
        profit = profit + vp[j].first * min(vp[j].second, temp);
        temp = temp - vp[j].second;
      }
      max_profit = max(max_profit, profit);
    }
  }
  cout << max_profit << endl;
  return 0;
}
