#include <bits/stdc++.h>
using namespace std;
const int N = 10;
int A[N][N * N], B[N][N * N], C[N][N * N];
int main() {
  int n, m, k;
  cin >> n >> m >> k;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    for (int j = 0; j < m; j++) cin >> A[i][j] >> B[i][j] >> C[i][j];
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (i == j) continue;
      vector<pair<int, int> > vec(m);
      for (int z = 0; z < m; z++) {
        vec[z] = {B[j][z] - A[i][z], C[i][z]};
      }
      sort(vec.rbegin(), vec.rend());
      int rem = k;
      int tempAns = 0;
      for (int z = 0; z < m && rem && vec[z].first > 0; z++) {
        tempAns += vec[z].first * min(vec[z].second, rem);
        rem -= min(rem, vec[z].second);
      }
      ans = max(ans, tempAns);
    }
  }
  cout << ans;
  return 0;
}
