#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:100000000")
using namespace std;
struct data {
  long a, b, c;
};
int main() {
  long n, m, k, i, j, l;
  cin >> n >> m >> k;
  vector<vector<data> > v(n, vector<data>(m));
  string tmp;
  for (i = 0; i < n; i++) {
    cin >> tmp;
    for (j = 0; j < m; j++) cin >> v[i][j].a >> v[i][j].b >> v[i][j].c;
  }
  long long ans = 0;
  for (l = 0; l < n; l++)
    for (j = 0; j < n; j++)
      if (l != j) {
        vector<pair<long, long> > d(m);
        for (i = 0; i < m; i++) {
          d[i].first = v[l][i].b - v[j][i].a;
          d[i].second = v[j][i].c;
        }
        sort(d.begin(), d.end());
        long sm = 0;
        long long p = 0;
        for (i = m - 1; i >= 0; i--) {
          if (d[i].first <= 0) break;
          if (d[i].second + sm > k) {
            p += (k - sm) * d[i].first;
            break;
          }
          p += d[i].second * d[i].first;
          sm += d[i].second;
        }
        ans = max(ans, p);
      }
  cout << ans << endl;
  return 0;
}
