#include <bits/stdc++.h>
struct node {
  int s[101][4];
} a[11];
struct cha {
  int val, m;
} b[101];
int comp(const void *p1, const void *p2) {
  return (*(cha *)p2).val - (*(cha *)p1).val;
}
int main() {
  int n, m, k, i, j, l, ans, max, num;
  char s[50];
  while (scanf("%d %d %d", &n, &m, &l) == 3) {
    max = 0;
    for (i = 1; i <= n; i++) {
      scanf("%s", s);
      for (j = 1; j <= m; j++)
        scanf("%d %d %d", &a[i].s[j][1], &a[i].s[j][2], &a[i].s[j][3]);
    }
    for (i = 1; i < n; i++) {
      for (j = i + 1; j <= n; j++) {
        ans = num = 0;
        for (k = 1; k <= m; k++) {
          b[k].val = a[j].s[k][2] - a[i].s[k][1];
          b[k].m = a[i].s[k][3];
        }
        qsort(&b[1], m, sizeof(b[1]), comp);
        for (k = 1; k <= m; k++) {
          if (b[k].val <= 0) break;
          if (num + b[k].m >= l) {
            ans += (l - num) * b[k].val;
            break;
          } else {
            ans += b[k].val * b[k].m;
            num += b[k].m;
          }
        }
        if (ans > max) max = ans;
        ans = num = 0;
        for (k = 1; k <= m; k++) {
          b[k].val = a[i].s[k][2] - a[j].s[k][1];
          b[k].m = a[j].s[k][3];
        }
        qsort(&b[1], m, sizeof(b[1]), comp);
        for (k = 1; k <= m; k++) {
          if (b[k].val <= 0) break;
          if (num + b[k].m >= l) {
            ans += (l - num) * b[k].val;
            break;
          } else {
            ans += b[k].val * b[k].m;
            num += b[k].m;
          }
        }
        if (ans > max) max = ans;
      }
    }
    printf("%d\n", max);
  }
  return 0;
}
