#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-9;
int a[11][111], b[11][111], c[11][111];
int main() {
  int n, m, k;
  int res = 0;
  cin >> n >> m >> k;
  string s;
  for (int i = 0; i < n; i++) {
    cin >> s;
    for (int j = 0; j < m; j++) cin >> a[i][j] >> b[i][j] >> c[i][j];
  }
  vector<pair<int, int> > v(m);
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) {
      if (i == j) continue;
      for (int r = 0; r < m; r++) {
        v[r].first = b[j][r] - a[i][r];
        v[r].second = c[i][r];
      }
      sort((v).begin(), (v).end());
      int K = k, sum = 0;
      for (int r = m - 1; r >= 0; r--) {
        if (v[r].first > 0) {
          if (v[r].second >= K) {
            sum += K * v[r].first;
            break;
          }
          K -= v[r].second;
          sum += v[r].second * v[r].first;
        } else
          break;
      }
      res = max(res, sum);
    }
  cout << res << endl;
  return 0;
}
