#include <bits/stdc++.h>
using namespace std;
int n, m, kp;
struct TNode {
  int a[105], b[105], c[105];
} nod[15], p1, p2;
char str[100];
int main() {
  int i, j, k, l, re, ri, t, maxl;
  while (scanf("%d%d%d", &n, &m, &kp) != EOF) {
    for (i = 0; i < n; i++) {
      scanf("%s", str);
      for (j = 0; j < m; j++)
        scanf("%d%d%d", &nod[i].a[j], &nod[i].b[j], &nod[i].c[j]);
    }
    for (i = 0, maxl = -1; i < n; i++) {
      for (j = 0; j < n; j++) {
        if (i == j) continue;
        p1 = nod[i];
        p2 = nod[j];
        for (k = 0; k < m; k++) {
          for (l = k + 1; l < m; l++) {
            if (p2.b[l] - p1.a[l] > p2.b[k] - p1.a[k]) {
              swap(p2.a[l], p2.a[k]);
              swap(p2.b[l], p2.b[k]);
              swap(p2.c[l], p2.c[k]);
              swap(p1.a[l], p1.a[k]);
              swap(p1.b[l], p1.b[k]);
              swap(p1.c[l], p1.c[k]);
            }
          }
        }
        t = 0, l = kp;
        for (k = 0; k < m; k++) {
          if (p2.b[k] - p1.a[k] <= 0) break;
          if (p1.c[k] <= l) {
            t += (p2.b[k] - p1.a[k]) * p1.c[k];
            l -= p1.c[k];
          } else {
            t += (p2.b[k] - p1.a[k]) * l;
            l = 0;
          }
          if (l == 0) break;
        }
        maxl = max(maxl, t);
      }
    }
    printf("%d\n", maxl);
  }
  return 0;
}
