#include <bits/stdc++.h>
using namespace std;
int n, m, k, a[15][110], b[15][110], c[15][110];
pair<int, int> opcao[110];
bool comp(pair<int, int> x, pair<int, int> y) { return x.first > y.first; }
int main() {
  char temp[50];
  scanf("%d %d %d", &n, &m, &k);
  for (int i = (0); i < (n); i++) {
    scanf("%s", temp);
    for (int j = (0); j < (m); j++) {
      scanf("%d %d %d", &a[i][j], &b[i][j], &c[i][j]);
    }
  }
  int ans = 0;
  for (int i = (0); i < (n); i++) {
    for (int j = (0); j < (n); j++) {
      if (i == j) continue;
      for (int h = (0); h < (m); h++) {
        opcao[h] = pair<int, int>(b[j][h] - a[i][h], c[i][h]);
      }
      sort(opcao, opcao + m, comp);
      int atual = 0, kk = k;
      for (int h = (0); h < (m); h++) {
        if (opcao[h].first < 0) break;
        if (opcao[h].second >= kk) {
          atual += kk * opcao[h].first;
          kk = 0;
          break;
        } else {
          kk -= opcao[h].second;
          atual += opcao[h].second * opcao[h].first;
        }
      }
      ans = max(ans, atual);
    }
  }
  printf("%d\n", ans);
  return 0;
}
