#include <bits/stdc++.h>
using namespace std;
int n, m, k;
int a[20][200];
int b[20][200];
int c[20][200];
struct Tt {
  int profit;
  int bulk;
  bool operator<(const Tt& a) const { return profit > a.profit; }
};
Tt temp[200];
char tc[100];
int main() {
  scanf("%d%d%d", &n, &m, &k);
  for (int i = 0; i < n; ++i) {
    scanf("%s", tc);
    for (int j = 0; j < m; ++j) scanf("%d%d%d", &a[i][j], &b[i][j], &c[i][j]);
  }
  int maxx = 0;
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < n; ++j) {
      if (i == j) continue;
      for (int l = 0; l < m; ++l) {
        temp[l].profit = b[j][l] - a[i][l];
        temp[l].bulk = c[i][l];
      }
      sort(temp, temp + m);
      int tk = k;
      int summ = 0;
      for (int l = 0; l < m && tk > 0 && temp[l].profit >= 0; ++l) {
        if (temp[l].bulk >= tk) {
          summ += tk * temp[l].profit;
          tk = 0;
        } else {
          summ += temp[l].bulk * temp[l].profit;
          tk -= temp[l].bulk;
        }
      }
      if (summ > maxx) maxx = summ;
    }
  printf("%d\n", maxx);
  return 0;
}
