#include <bits/stdc++.h>
using namespace std;
const int MXN = 20;
const int MXM = 110;
const int MXL = 15;
char name[MXN][MXL];
int a[MXN][MXM];
int b[MXN][MXM];
int c[MXN][MXM];
pair<int, int> tmp[MXM];
int main() {
  int n, m, space;
  scanf("%d%d%d", &n, &m, &space);
  for (int i = 0; i < (n); i++) {
    gets(name[i]);
    gets(name[i]);
    for (int j = 0; j < (m); j++) {
      scanf("%d%d%d", &a[i][j], &b[i][j], &c[i][j]);
    }
  }
  int result = 0;
  for (int i = 0; i < (n); i++) {
    for (int j = 0; j < (n); j++) {
      for (int k = 0; k < (m); k++) {
        tmp[k] = make_pair(b[j][k] - a[i][k], c[i][k]);
      }
      sort(tmp, tmp + m);
      int res = 0;
      int rest = space;
      for (int k = m - 1; k >= 0 && rest; k--) {
        if (tmp[k].first < 0) break;
        if (tmp[k].second > rest) tmp[k].second = rest;
        rest -= tmp[k].second;
        res += tmp[k].first * tmp[k].second;
      }
      result = max(result, res);
    }
  }
  printf("%d\n", result);
}
