#include <bits/stdc++.h>
using namespace std;
string name[20];
vector<int> a[20];
vector<int> b[20];
vector<int> c[20];
int n, m, k;
int solve(int ost, int src, int dest) {
  int maxdif = -1, nmax = -1;
  for (int i = 0; i < m; ++i)
    if (b[dest][i] - a[src][i] > maxdif) {
      maxdif = b[dest][i] - a[src][i];
      nmax = i;
    }
  if (nmax == -1) return 0;
  int i = nmax;
  if (c[src][i] >= ost) return maxdif * ost;
  ost -= c[src][i];
  int ans = c[src][i] * maxdif;
  int ct = c[src][i];
  c[src][i] = 0;
  int at = a[src][i];
  a[src][i] = 1000000000ll;
  ans += solve(ost, src, dest);
  c[src][i] = ct;
  a[src][i] = at;
  return ans;
}
int main(int argc, char** argv) {
  cin >> n >> m >> k;
  int a0, b0, c0;
  for (int i = 0; i < n; ++i) {
    cin >> name[i];
    for (int j = 0; j < m; ++j) {
      cin >> a0 >> b0 >> c0;
      a[i].push_back(a0);
      b[i].push_back(b0);
      c[i].push_back(c0);
    }
  }
  int ans = 0;
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < n; ++j)
      if (i != j) ans = max(ans, solve(k, i, j));
  cout << ans << endl;
  return 0;
}
