#include <bits/stdc++.h>
using namespace std;
int n, m, k;
string s;
int a[300][300], b[300][300], c[300][300];
pair<int, int> q[2000000];
int solve(int i, int j) {
  int ret = 0, t = 0;
  for (int idx = 0; idx < m; idx++)
    q[t++] = make_pair(b[j][idx] - a[i][idx], c[i][idx]);
  sort(q, q + t);
  int left = k;
  for (int idx = m - 1; idx >= 0; idx--) {
    if (q[idx].first < 0) break;
    int x = min(left, q[idx].second);
    ret += x * q[idx].first;
    left -= x;
  }
  return ret;
}
int main() {
  scanf("%d%d%d", &n, &m, &k);
  for (int i = 0; i < n; i++) {
    cin >> s;
    for (int j = 0; j < m; j++) scanf("%d%d%d", &a[i][j], &b[i][j], &c[i][j]);
  }
  int res = 0;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++)
      if (i != j) res = max(res, solve(i, j));
  cout << res << endl;
  return 0;
}
