#include <bits/stdc++.h>
using namespace std;
int a[11][101], b[11][101], c[11][101];
vector<int> pf;
int get_max() {
  int mx = 0, idx = -1;
  for (int i = 0; i < pf.size(); ++i)
    if (pf[i] > mx) mx = pf[i], idx = i;
  if (idx != -1) pf[idx] *= -1;
  return idx;
}
int main() {
  string s;
  int n, m, k, ans = 0;
  cin >> n >> m >> k;
  pf = vector<int>(m, 0);
  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 f = 0; f < n; ++f)
    for (int e = 0; e < n; ++e)
      if (f != e) {
        for (int i = 0; i < m; ++i) pf[i] = b[e][i] - a[f][i];
        int get = k, sum = 0;
        while (get > 0) {
          int idx = get_max();
          if (idx == -1) break;
          int tmp = min(c[f][idx], get);
          get -= tmp;
          sum += tmp * pf[idx] * -1;
        }
        ans = max(ans, sum);
      }
  cout << ans << endl;
  return 0;
}
