#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, k;
  string s[10];
  cin >> n >> m >> k;
  int a[10][100], b[10][100], c[10][100];
  for (int i = 0; i < n; i++) {
    cin >> s[i];
    for (int j = 0; j < m; j++) cin >> a[i][j] >> b[i][j] >> c[i][j];
  }
  int prof[10][10], e[100];
  memset(prof, 0, sizeof(prof));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (i == j) continue;
      for (int l = 0; l < m; l++) e[l] = c[i][l];
      int kk = k;
      while (kk > 0) {
        int mi = -1, v = 0;
        for (int l = 0; l < m; l++) {
          if (e[l] == 0) continue;
          if (b[j][l] - a[i][l] > v) {
            v = b[j][l] - a[i][l];
            mi = l;
          }
        }
        if (mi == -1) break;
        if (kk >= e[mi]) {
          kk -= e[mi];
          prof[i][j] += e[mi] * v;
          e[mi] = 0;
        } else {
          prof[i][j] += kk * v;
          break;
        }
      }
    }
  }
  int mv = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (prof[i][j] > mv) mv = prof[i][j];
    }
  }
  cout << mv << endl;
  return 0;
}
