#include <bits/stdc++.h>
int buy[12][105], v[12][105], money[105], sale[12][105], space[105];
int main() {
  int n, m, s, max = 0, x, y, t, k, sum, total, i, j;
  char str[105];
  scanf("%d%d%d", &n, &m, &s);
  for (i = 0; i < n; i++) {
    scanf("%s", str);
    for (j = 0; j < m; j++) scanf("%d%d%d", &buy[i][j], &sale[i][j], &v[i][j]);
  }
  for (i = 0; i < n; i++) {
    for (j = 0; j < n; j++) {
      if (i == j) continue;
      sum = 0;
      total = s;
      for (k = 0; k < m; k++) {
        if (sale[j][k] > buy[i][k])
          money[k] = sale[j][k] - buy[i][k];
        else
          money[k] = 0;
        space[k] = v[i][k];
      }
      for (x = 0; x < m - 1; x++)
        for (y = 0; y < m - x - 1; y++) {
          if (money[y] < money[y + 1]) {
            t = money[y];
            money[y] = money[y + 1];
            money[y + 1] = t;
            t = space[y];
            space[y] = space[y + 1];
            space[y + 1] = t;
          }
        }
      for (k = 0; k < m; k++) {
        if (space[k] >= total) {
          sum += money[k] * total;
          break;
        } else {
          sum += money[k] * space[k];
          total -= space[k];
        }
      }
      if (sum > max) max = sum;
    }
  }
  printf("%d\n", max);
  return 0;
}
