#include <bits/stdc++.h>
using namespace std;
int n, m, space;
int sell[111][111];
int buy[111][111];
int num[111][111];
bool read() {
  if (scanf("%d%d%d", &n, &m, &space) == EOF) return false;
  for (int i = 0; i < n; i++) {
    scanf("%*s");
    for (int j = 0; j < m; j++) {
      scanf("%d%d%d", &buy[i][j], &sell[i][j], &num[i][j]);
    }
  }
  return true;
}
struct trade {
  int num, v;
  bool operator<(const trade& b) const { return v > b.v; }
};
int calc(vector<trade> a) {
  int res = 0;
  int item = space;
  for (int i = 0; i < a.size(); i++) {
    if (item && a[i].v > 0) {
      int take = min(item, a[i].num);
      item -= take;
      res += take * a[i].v;
    }
  }
  return res;
}
void process() {
  int res = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      vector<trade> a;
      vector<trade> b;
      for (int k = 0; k < m; k++) {
        trade x;
        x.v = sell[j][k] - buy[i][k];
        x.num = num[i][k];
        a.push_back(x);
        x.v = sell[i][k] - buy[j][k];
        x.num = num[j][k];
        b.push_back(x);
      }
      sort(a.begin(), a.end());
      sort(b.begin(), b.end());
      res = max(res, calc(a));
      res = max(res, calc(b));
    }
  }
  printf("%d\n", res);
}
int main() {
  while (read()) process();
}
