#include <bits/stdc++.h>
using namespace std;
int best = 0;
int n, m, k;
int a[10][100];
int b[10][100];
int c[10][100];
void trade(int from, int to) {
  vector<pair<int, int> > v;
  for (int i = 0; i < m; i++) {
    v.push_back(make_pair(((b[to][i] - a[from][i])), (c[from][i])));
  }
  sort(v.begin(), v.end());
  int idx = m - 1, kk = k, pf = 0;
  while (idx >= 0 && v[idx].first > 0 && k > 0) {
    pf += v[idx].first * min(v[idx].second, kk);
    kk -= min(v[idx].second, kk);
    idx--;
  }
  if (pf > best) best = pf;
}
int main() {
  cin >> n >> m >> k;
  string s;
  for (int i = 0; i < n; i++) {
    cin >> s;
    for (int j = 0; j < m; j++) cin >> a[i][j] >> b[i][j] >> c[i][j];
  }
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) {
      if (i == j) continue;
      trade(i, j);
    }
  cout << best;
  return 0;
}
