#include <bits/stdc++.h>
using namespace std;
const int MaxN = 10 + 5;
const int MaxM = 100 + 5;
const int MaxK = 100 + 5;
int N, M, K, A[MaxN][MaxM], B[MaxN][MaxM], C[MaxN][MaxM];
string Names[MaxN];
int main(void) {
  cin >> N >> M >> K;
  for (int i = 0; i < N; i++) {
    cin >> Names[i];
    for (int j = 0; j < M; j++) cin >> A[i][j] >> B[i][j] >> C[i][j];
  }
  int Sol = 0;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      if (i == j) continue;
      vector<pair<int, int> > X;
      for (int k = 0; k < M; k++)
        X.push_back(make_pair(B[j][k] - A[i][k], C[i][k]));
      sort(X.begin(), X.end());
      reverse(X.begin(), X.end());
      int idx = 0, CurrK = K, CurrSol = 0;
      while (idx < M) {
        if (X[idx].first <= 0) break;
        int Add = min(X[idx].second, CurrK);
        CurrK -= Add;
        CurrSol += Add * X[idx].first;
        idx++;
      }
      Sol = max(CurrSol, Sol);
    }
  }
  cout << Sol << endl;
  return 0;
}
