#include <bits/stdc++.h>
int n, m, K;
int a[201][201], b[201][201], c[201][201];
int f[201][201];
int queue[201], cl, op;
int ans = 0;
char ttt[201];
int main() {
  int i, j, k, l, o, p;
  int value, maxnum, weight;
  scanf("%d%d%d", &n, &m, &K);
  for (i = 1; i <= n; ++i) {
    scanf("%s", ttt);
    for (j = 1; j <= m; ++j) {
      scanf("%d%d%d", &a[i][j], &b[i][j], &c[i][j]);
    }
  }
  for (i = 1; i <= n; ++i)
    for (j = 1; j <= n; ++j)
      if (i != j) {
        for (k = 0; k <= m + 1; ++k)
          for (p = 0; p <= K; ++p) f[k][p] = 0;
        for (k = 1; k <= m; ++k) {
          value = b[j][k] - a[i][k];
          maxnum = c[i][k];
          cl = op = 0;
          for (p = 0; p <= K; ++p) {
            if (queue[cl] < p - maxnum) ++cl;
            while (cl < op &&
                   f[k - 1][queue[op - 1]] + (p - queue[op - 1]) * value <
                       f[k - 1][p])
              op--;
            queue[op++] = p;
            f[k][p] = f[k - 1][queue[cl]] + (p - queue[cl]) * value;
            ans = ((f[k][p]) > (ans) ? (f[k][p]) : (ans));
          }
        }
      }
  printf("%d\n", ans);
  return 0;
}
