#include <bits/stdc++.h>
using namespace std;
int a[20][110], b[20][110], c[20][110];
struct node {
  int x, y;
};
node t[110];
bool cmp(node x, node y) {
  if (x.x != y.x) return x.x > y.x;
  return x.y < y.y;
}
int main() {
  int n, m, cc;
  while (scanf("%d%d%d", &n, &m, &cc) == 3) {
    for (int i = 0; i < n; i++) {
      scanf("%*s");
      for (int j = 0; j < m; j++) scanf("%d%d%d", &a[i][j], &b[i][j], &c[i][j]);
    }
    int ans = 0;
    for (int i = 0; i < n; i++)
      for (int j = 0; j < n; j++) {
        for (int k = 0; k < m; k++) {
          t[k].x = b[j][k] - a[i][k];
          t[k].y = c[i][k];
        }
        sort(t, t + m, cmp);
        int tans = 0, left = cc;
        for (int k = 0; k < m; k++) {
          if (t[k].x <= 0) break;
          if (left == 0) break;
          if (left >= t[k].y) {
            tans += t[k].x * t[k].y;
            left -= t[k].y;
          } else {
            tans += left * t[k].x;
            left = 0;
          }
        }
        ans = max(ans, tans);
      }
    printf("%d\n", ans);
  }
  return 0;
}
