#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, k;
  cin >> n >> m >> k;
  int a[n][m][3];
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    for (int j = 0; j < m; j++) cin >> a[i][j][0] >> a[i][j][1] >> a[i][j][2];
  }
  int ans = 0;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) {
      vector<pair<int, int> > b(m);
      for (int l = 0; l < m; l++) {
        b[l].second = a[i][l][2];
        b[l].first = a[i][l][0] - a[j][l][1];
      }
      sort(b.begin(), b.end());
      int z = k;
      int newans = 0;
      for (int l = 0; b[l].first < 0 && l < m && z > 0; l++) {
        if (z > b[l].second) {
          newans += (b[l].second) * (-b[l].first);
          z -= b[l].second;
        } else {
          newans += (z) * (-b[l].first);
          z = 0;
        }
      }
      ans = max(ans, newans);
    }
  cout << ans << endl;
  return 0;
}
