#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, k;
  cin >> n >> m >> k;
  int a[n][m];
  int b[n][m];
  int c[n][m];
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    for (int j = 0; j < m; j++) {
      int d, e, f;
      cin >> d >> e >> f;
      a[i][j] = d;
      b[i][j] = e;
      c[i][j] = f;
    }
  }
  int ans = 0;
  vector<pair<int, int> > d(m);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (i == j) {
        continue;
      }
      int lans = 0;
      for (int l = 0; l < m; l++) {
        d[l] = make_pair(b[j][l] - a[i][l], c[i][l]);
      }
      sort(d.begin(), d.end(), greater<pair<int, int> >());
      int ck = 0;
      int l = 0;
      while (l < m && ck < k && d[l].first > 0) {
        int cs = min(k - ck, d[l].second);
        lans += (d[l].first * cs);
        ck += cs;
        l++;
      }
      ans = max(ans, lans);
    }
  }
  cout << ans;
  return 0;
}
