#include <bits/stdc++.h>
using namespace std;
int n, m, k;
int buy[10][102];
int sell[10][102];
int items[10][102];
int profit, maxProfit;
pair<int, int> benefit[102];
char line[100];
int main() {
  scanf("%d%d%d", &n, &m, &k);
  for (int i = 0; i < n; ++i) {
    scanf("%s", line);
    for (int j = 0; j < m; ++j) {
      scanf("%d", &buy[i][j]);
      scanf("%d", &sell[i][j]);
      scanf("%d", &items[i][j]);
    }
  }
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      if (i != j) {
        for (int p = 0; p < m; ++p) {
          benefit[p].first = sell[j][p] - buy[i][p];
          benefit[p].second = items[i][p];
        }
        sort(benefit, benefit + m);
        int cant = 0, id = m - 1;
        profit = 0;
        while (id >= 0 && benefit[id].first > 0 && cant < k) {
          profit += benefit[id].first * min(benefit[id].second, k - cant);
          cant += min(benefit[id].second, k - cant);
          id--;
        }
        if (maxProfit < profit) {
          maxProfit = profit;
        }
      }
    }
  }
  printf("%d", maxProfit);
  return 0;
}
