#include <bits/stdc++.h>
using namespace std;
int n, m, k, a[15][109], b[15][109], c[15][109], from, to;
char str[20];
bool cmp(int x, int y) { return a[from][x] - b[to][x] < a[from][y] - b[to][y]; }
int trade() {
  int ord[m], ret = 0, cap = k, i = 0, qt;
  for (int x = 0; x < m; x++) ord[x] = x;
  sort(ord, ord + m, cmp);
  while (i < m && cap > 0) {
    if (a[from][ord[i]] > b[to][ord[i]]) break;
    qt = min(cap, c[from][ord[i]]);
    cap -= qt;
    ret += qt * (b[to][ord[i]] - a[from][ord[i]]);
    i++;
  }
  return ret;
}
int main() {
  while (scanf("%d%d%d", &n, &m, &k) == 3) {
    for (int x = 0; x < n; x++) {
      scanf("%s", str);
      for (int y = 0; y < m; y++) scanf("%d%d%d", &a[x][y], &b[x][y], &c[x][y]);
    }
    int ans = 0;
    for (int x = 0; x < n; x++)
      for (int y = 0; y < n; y++)
        if (x != y) {
          from = x;
          to = y;
          ans = max(ans, trade());
        }
    printf("%d\n", ans);
  }
  return 0;
}
