#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long int n, m, c;
  cin >> n >> m >> c;
  vector<vector<vector<long long int>>> v(
      n, vector<vector<long long int>>(m, vector<long long int>(3)));
  for (long long int i = 0; i < n; i++) {
    string s;
    cin >> s;
    for (long long int j = 0; j < m; j++)
      for (long long int k = 0; k < 3; k++) cin >> v[i][j][k];
  }
  long long int ans = 0;
  for (long long int i = 0; i < n; i++) {
    for (long long int j = 0; j < n; j++) {
      if (i == j) continue;
      vector<pair<long long int, long long int>> diff;
      for (long long int k = 0; k < m; k++) {
        long long int costDiff = v[j][k][1] - v[i][k][0];
        long long int avail = v[i][k][2];
        diff.push_back(make_pair(costDiff, avail));
      }
      sort(diff.begin(), diff.end(),
           greater<pair<long long int, long long int>>());
      long long int p = 0, cap = c, idx = 0;
      while (cap > 0 && idx < m && diff[idx].first > 0) {
        long long int trade = min(cap, diff[idx].second);
        p += trade * diff[idx].first;
        cap -= trade;
        if (trade == diff[idx].second) idx++;
      }
      ans = max(ans, p);
    }
  }
  cout << ans;
  return 0;
}
