#include <bits/stdc++.h>
using namespace std;
int main() {
  char temp[11];
  int n, m, k;
  cin >> n >> m >> k;
  int a[10][100], b[10][100], c[10][100];
  for (int i = 0; i < n; i++) {
    cin >> temp;
    for (int j = 0; j < m; j++) cin >> a[i][j] >> b[i][j] >> c[i][j];
  }
  int maxi = 0;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) {
      if (i == j) continue;
      vector<pair<int, int> > diff(m);
      for (int t = 0; t < m; t++) diff[t] = make_pair(b[j][t] - a[i][t], t);
      sort(diff.rbegin(), diff.rend());
      int kc = k, cur = 0;
      for (int t = 0; kc > 0 && t < m && diff[t].first > 0; t++) {
        cur += min(kc, c[i][diff[t].second]) * diff[t].first;
        kc -= min(kc, c[i][diff[t].second]);
      }
      maxi = max(maxi, cur);
    }
  cout << maxi << endl;
  return 0;
}
