#include <bits/stdc++.h>
using namespace std;
const long double EPS = 1E-9;
const int INF = (int)1E9;
const long long INF64 = (long long)1E18;
bool mycmp(pair<int, int> a, pair<int, int> b) {
  if (a.first > b.first) return 1;
  return 0;
}
int main() {
  ios_base::sync_with_stdio(false);
  int n, m, K;
  cin >> n >> m >> K;
  int a[n][m], b[n][m], c[n][m];
  for (int i = 0; i < (int)(n); i++) {
    string s;
    cin >> s;
    for (int j = 0; j < (int)(m); j++) cin >> a[i][j] >> b[i][j] >> c[i][j];
  }
  int tot = 0;
  for (int i = 0; i < (int)(n); i++) {
    for (int j = 0; j < (int)(n); j++) {
      if (i == j) continue;
      vector<pair<int, int> > v;
      for (int k = 0; k < (int)(m); k++) {
        if (b[j][k] > a[i][k])
          v.push_back(make_pair(b[j][k] - a[i][k], c[i][k]));
      }
      sort(v.begin(), v.end(), mycmp);
      int temp = 0, t = 0;
      for (int i = 0; i < (int)(v.size()); i++) {
        if (t > K) break;
        temp += v[i].first * min(K - t, v[i].second);
        t = t + min(K - t, v[i].second);
      }
      tot = max(tot, temp);
    }
  }
  cout << tot;
}
