#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, KK, A[12][110][3];
  string word;
  cin >> n >> m >> KK;
  for (int i = 0; i < n; ++i) {
    cin >> word;
    for (int j = 0; j < m; ++j)
      for (int k = 0; k < 3; ++k) cin >> A[i][j][k];
  }
  int res = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j)
      if (i != j) {
        int K = KK;
        vector<pair<int, int> > v;
        for (int k = 0; k < m; ++k) {
          if ((A[i][k][1] - A[j][k][0]) > 0)
            v.push_back(make_pair((A[i][k][1] - A[j][k][0]), A[j][k][2]));
        }
        int opc = 0;
        sort(v.rbegin(), v.rend());
        for (int k = 0; k < v.size(); ++k) {
          opc += v[k].first * min(K, v[k].second);
          K -= min(K, v[k].second);
        }
        res = max(opc, res);
      }
  }
  cout << res << "\n";
  return 0;
}
