#include <bits/stdc++.h>
using namespace std;
const long double PI = 3.141592653589793238462643l;
int a[200][200], b[200][200], c[200][200];
int main() {
  int n, m, k;
  cin >> n >> m >> k;
  for (int i = 0; i < int(n); i++) {
    string s;
    cin >> s;
    for (int j = 0; j < int(m); j++) {
      cin >> a[i][j];
      cin >> b[i][j];
      cin >> c[i][j];
    }
  }
  int ans = 0;
  for (int i1 = 0; i1 < int(n); i1++) {
    for (int i2 = 0; i2 < int(n); i2++) {
      vector<pair<int, int> > q(0);
      for (int j = 0; j < int(m); j++) {
        if (b[i2][j] > a[i1][j]) {
          q.push_back(make_pair(a[i1][j] - b[i2][j], c[i1][j]));
        }
      }
      sort(q.begin(), q.end());
      int t = 0;
      int s = 0;
      for (int j = 0; j < int(q.size()); j++) {
        int e = min(k - t, q[j].second);
        s -= e * q[j].first;
        t += e;
      }
      ans = max(ans, s);
    }
  }
  cout << ans;
  return 0;
}
