#include <bits/stdc++.h>
using namespace std;
long long a[15][110], b[15][110], c[15][110];
int main() {
  long long n, m, k;
  cin >> n >> m >> k;
  for (long long i = 1; i <= n; i++) {
    string s;
    cin >> s;
    for (long long j = 1; j <= m; j++) {
      cin >> a[i][j] >> b[i][j] >> c[i][j];
    }
  }
  long long ans = 0;
  for (long long i = 1; i <= n; i++) {
    for (long long j = 1; j <= n; j++) {
      if (i != j) {
        vector<pair<long long, long long> > v;
        for (long long l = 1; l <= m; l++) {
          if (b[j][l] - a[i][l] > 0)
            v.push_back(make_pair(b[j][l] - a[i][l], c[i][l]));
        }
        sort(v.begin(), v.end());
        long long mx = 0, L = v.size();
        long long item = 0;
        for (long long l = L - 1; l >= 0; l--) {
          if (v[l].second + item < k)
            mx += v[l].first * v[l].second, item += v[l].second;
          else
            mx += v[l].first * (k - item), item = k;
        }
        ans = max(mx, ans);
      }
    }
  }
  cout << ans << '\n';
  return 0;
}
