#include <bits/stdc++.h>
using namespace std;
int a[11][111], b[11][111], c[11][111];
char str[111];
struct node {
  int n, v;
  node(int _n, int _v) { n = _n, v = _v; }
  node() {}
  friend bool operator<(node a, node b) { return a.v > b.v; }
} p[111];
int main() {
  int n, m, cc;
  while (~scanf("%d%d%d", &n, &m, &cc)) {
    for (int i = 0; i < n; i++) {
      scanf(" %*s", str);
      for (int j = 0; j < m; j++) {
        scanf("%d %d %d", &a[i][j], &b[i][j], &c[i][j]);
      }
    }
    int res = 0;
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        if (i == j) continue;
        int t = 0, cnt = 0, q = cc;
        for (int k = 0; k < m; k++) {
          if (b[j][k] > a[i][k]) p[cnt++] = node(c[i][k], (b[j][k] - a[i][k]));
        }
        sort(p, p + cnt);
        for (int k = 0; k < cnt; k++) {
          if (q <= p[k].n) {
            t += q * p[k].v;
            break;
          } else {
            t += p[k].n * p[k].v;
            q -= p[k].n;
          }
        }
        res = max(res, t);
      }
    }
    printf("%d\n", res);
  }
  return 0;
}
