#include <bits/stdc++.h>
using namespace std;
struct Elem {
  int a, b, c;
};
struct Benef {
  int money, amount;
  Benef(int m, int a) : money(m), amount(a) {}
  bool operator<(const Benef &a) const { return money > a.money; }
};
int main(int narg, char **arg) {
  int n, m, amount_total;
  cin >> n >> m >> amount_total;
  Elem elem[n][m];
  for (int i = 0; i < n; i++) {
    string str;
    cin >> str;
    for (int j = 0; j < m; j++) {
      cin >> elem[i][j].a >> elem[i][j].b >> elem[i][j].c;
    }
  }
  int maxim = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (i == j) continue;
      vector<Benef> benef;
      for (int k = 0; k < m; k++) {
        if (elem[j][k].b - elem[i][k].a > 0 && elem[i][k].c > 0)
          benef.push_back(Benef(elem[j][k].b - elem[i][k].a, elem[i][k].c));
      }
      sort(benef.begin(), benef.end());
      int amount = 0, k = 0, earning = 0;
      while (k < int(benef.size()) && amount < amount_total) {
        if (benef[k].amount >= amount_total - amount) {
          int rest = amount_total - amount;
          amount += rest;
          earning += benef[k].money * rest;
          break;
        } else {
          amount += benef[k].amount;
          earning += benef[k].amount * benef[k].money;
          k++;
        }
      }
      maxim = max(maxim, earning);
    }
  }
  cout << maxim << endl;
  return 0;
}
