#include <bits/stdc++.h>
using namespace std;
const long double eps = 1e-9;
const long double pi = acos(-1.0);
int gcd(int a, int b) { return (b == 0) ? a : gcd(b, a % b); }
int xabs(int a) { return a > 0 ? a : -a; }
int mod = 1e+9 + 7;
struct plan {
  string name;
  vector<vector<int>> trade;
};
int main() {
  int n, m, q;
  cin >> n >> m >> q;
  vector<plan> pls;
  for (int i = 0; i < n; i++) {
    string name;
    cin >> name;
    plan pl;
    pl.name = name;
    for (int k = 0; k < m; k++) {
      vector<int> w(3);
      cin >> w[0] >> w[1] >> w[2];
      pl.trade.push_back(w);
    }
    pls.push_back(pl);
  }
  long long res = 0;
  for (int i = 0; i < n; i++) {
    for (int k = 0; k < n; k++) {
      plan a = pls[i];
      plan b = pls[k];
      if (i != k) {
        vector<pair<long long, int>> pr;
        for (int j = 0; j < m; j++) {
          if (a.trade[j][0] < b.trade[j][1]) {
            pr.push_back(
                make_pair((b.trade[j][1] - a.trade[j][0]), a.trade[j][2]));
          }
        }
        sort(pr.rbegin(), pr.rend());
        int z = q;
        long long result = 0;
        for (int j = 0; j < pr.size(); j++) {
          if (pr[j].second <= z) {
            result += pr[j].first * pr[j].second;
            z -= pr[j].second;
          } else {
            result += pr[j].first * z;
            z = 0;
            break;
          }
        }
        res = max(result, res);
      }
    }
  }
  cout << res << endl;
  return 0;
}
