#include <bits/stdc++.h>
using namespace std;
const double EPS = 1e-9;
const double PI = 3.1415926535897932384626433832795;
long long i64INF = 1000LL * 1000LL * 1000LL * 1000LL * 1000LL * 1000LL;
long long i32INF = 1000 * 1000 * 1000;
long long a[11][101];
long long b[11][101];
long long c[11][101];
int main() {
  long long n, m, k;
  cin >> n >> m >> k;
  string name;
  for (long long i = 0; i < n; i++) {
    cin >> name;
    for (long long j = 0; j < m; j++) cin >> a[i][j] >> b[i][j] >> c[i][j];
  }
  long long res = 0;
  for (long long from = 0; from < n; from++) {
    for (long long to = 0; to < n; to++) {
      vector<pair<long long, long long> > v;
      for (long long i = 0; i < m; i++)
        v.push_back(make_pair(b[to][i] - a[from][i], c[from][i]));
      sort(v.rbegin(), v.rend());
      long long money = 0;
      long long left = k;
      for (long long i = 0; i < v.size(); i++) {
        if (v[i].first < 0) break;
        if (v[i].second >= left) {
          money += left * v[i].first;
          break;
        } else {
          money += v[i].second * v[i].first;
          left -= v[i].second;
        }
      }
      res = max(res, money);
    }
  }
  cout << res << endl;
  return 0;
}
