#include <bits/stdc++.h>
using namespace std;
int a[15][1005];
int b[15][1005];
int c[15][1005];
void oku() {
  int n, m, K;
  cin >> n >> m >> K;
  string s;
  int x, y, z;
  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];
    }
  }
  int best = 0, cost, q, take, u, v, cc, loc;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) {
      if (i == j) continue;
      priority_queue<pair<int, int> > pq;
      for (int k = 0; k < m; k++) {
        cost = b[j][k] - a[i][k];
        pq.push(make_pair(cost, c[i][k]));
      }
      for (take = K, loc = 0; take > 0 && !pq.empty();) {
        u = pq.top().first;
        cc = pq.top().second;
        pq.pop();
        cc = min(cc, take);
        if (u > 0) loc += u * cc;
        take -= cc;
      }
      best = max(best, loc);
    }
  cout << best;
}
int main() {
  oku();
  return 0;
}
