#include <bits/stdc++.h>
using namespace std;
struct item {
  int b, s, c;
  item() {}
  item(int b, int s, int c) : b(b), s(s), c(c) {}
} in[11][111];
char danese[12];
pair<int, int> aux[111];
int main() {
  int n, m, k;
  scanf("%d %d %d", &n, &m, &k);
  for (int i = (0); i < (n); ++i) {
    scanf("%s", danese);
    for (int j = (0); j < (m); ++j) {
      int a, b, c;
      scanf("%d %d %d", &a, &b, &c);
      in[i][j] = item(a, b, c);
    }
  }
  int mx = 0;
  for (int i = (0); i < (n); ++i)
    for (int j = (0); j < (n); ++j) {
      if (i == j) continue;
      for (int z = (0); z < (m); ++z)
        aux[z] = pair<int, int>(in[j][z].s - in[i][z].b, z);
      sort(aux, aux + m);
      int act = k;
      int tmp = 0;
      for (int z = m - 1; z >= 0 && act > 0; --z) {
        if (aux[z].first <= 0) continue;
        int id = aux[z].second;
        int qtd = min(act, in[i][id].c);
        tmp += qtd * aux[z].first;
        act -= qtd;
      }
      mx = max(mx, tmp);
    }
  printf("%d\n", mx);
}
