#include <bits/stdc++.h>
int main() {
  int n, m, k, c1 = 0, sum = 0, qnt = 0, a, b, c, buy = 0, max = 0;
  char name[20];
  scanf("%d %d %d", &n, &m, &k);
  int mas[n + 1][m + 1][3];
  for (a = 0; a < n; a++) {
    scanf("%s", name);
    for (b = 0; b < m; b++) {
      scanf("%d %d %d", &mas[a][b][0], &mas[a][b][1], &mas[a][b][2]);
    }
  }
  int dif[m + 1][2];
  int une[n + 1][n + 1];
  for (a = 0; a < n; a++) {
    for (b = 0; b < n; b++) {
      if (b == a) {
        une[a][b] = 0;
        goto xax;
      }
      for (c = 0; c < m; c++) {
        dif[c][0] = mas[b][c][1] - mas[a][c][0];
        dif[c][1] = mas[a][c][2];
      }
      buy = 0;
    bgn:
      while (buy < k) {
        max = 0;
        c1 = -1;
        for (c = 0; c < m; c++) {
          if (dif[c][0] > max) {
            max = dif[c][0];
            qnt = dif[c][1];
            c1 = c;
          }
        }
        dif[c1][0] = 0;
        dif[c1][1] = 0;
        if (max > 0) {
          if (qnt > (k - buy)) qnt = (k - buy);
          sum = sum + max * qnt;
          buy = buy + qnt;
          goto bgn;
        } else
          buy = k;
      }
      une[a][b] = sum;
    xax:
      sum = 0;
      qnt = 0;
    }
  }
  max = 0;
  for (a = 0; a < n; a++) {
    for (b = 0; b < n; b++) {
      if (une[a][b] > max) max = une[a][b];
    }
  }
  printf("%d", max);
  return 0;
}
