#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n, m, k;
  cin >> n >> m >> k;
  long long a[n + 1][m + 1], b[n + 1][m + 1], c[n + 1][m + 1], i, j, x;
  string s;
  for (i = 1; i <= n; ++i) {
    cin >> s;
    for (j = 1; j <= m; ++j) cin >> a[i][j] >> b[i][j] >> c[i][j];
  }
  long long ma = 0, rem, ans;
  vector<pair<long long, long long> > v;
  for (i = 1; i <= n; ++i) {
    for (j = 1; j <= n; ++j) {
      v.clear();
      for (x = 1; x <= m; ++x)
        v.push_back({max(0LL, b[i][x] - a[j][x]), c[j][x]});
      sort(v.begin(), v.end());
      rem = k, ans = 0;
      for (x = v.size() - 1; x >= 0; --x) {
        if (rem >= v[x].second) {
          ans += v[x].first * v[x].second;
          rem -= v[x].second;
        } else {
          ans += v[x].first * rem;
          rem = 0;
          break;
        }
      }
      ma = max(ma, ans);
    }
  }
  cout << ma;
  return 0;
}
