#include <bits/stdc++.h>
using namespace std;
const int N = 110, INF = 1e9;
pair<long long, long long> r[N];
long long a[N][N], b[N][N], c[N][N], n, m, k;
long long ans = 0;
string s;
int main() {
  cin >> n >> m >> k;
  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) {
        long long res = 0;
        for (int q = 0; q < m; q++) {
          r[q].first = b[j][q] - a[i][q];
          r[q].second = q;
        }
        sort(r, r + m);
        long long cnt = 0;
        for (int q = m - 1; cnt < k && q >= 0; q--) {
          int t = min(c[i][r[q].second], k - cnt);
          if (r[q].first > 0) {
            cnt += t;
            res += t * r[q].first;
          }
        }
        ans = max(ans, res);
      }
  cout << max(0ll, ans);
  return 0;
}
