#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, k;
  cin >> n >> m >> k;
  string s;
  int A[n][m], B[n][m], C[n][m];
  vector<pair<int, int>> pd(m);
  int ind, allowance;
  for (int i = 0; i <= n - 1; i++) {
    cin >> s;
    for (int j = 0; j <= m - 1; j++) {
      scanf("%d %d %d", &A[i][j], &B[i][j], &C[i][j]);
    }
  }
  long long sum, maxsum = 0;
  for (int i1 = 0; i1 <= n - 1; i1++) {
    for (int i2 = 0; i2 <= n - 1; i2++) {
      if (i1 != i2) {
        sum = 0;
        for (int j = 0; j <= m - 1; j++) {
          pd[j] = make_pair(A[i1][j] - B[i2][j], C[i1][j]);
        }
        sort(pd.begin(), pd.end());
        ind = 0;
        allowance = k;
        while ((ind < m) && (pd[ind].first < 0) && (allowance > 0)) {
          if (allowance > pd[ind].second) {
            sum -= pd[ind].first * pd[ind].second;
            allowance -= pd[ind].second;
            ind++;
          } else {
            sum -= pd[ind].first * allowance;
            allowance = 0;
            break;
          }
        }
        maxsum = max(sum, maxsum);
      }
    }
  }
  cout << maxsum << endl;
  return 0;
}
