#include <bits/stdc++.h>
using namespace std;
const int INF = 1000000000;
const int prime = 9241;
const long double pi = acos(-1.);
int a[15][105];
int b[15][105];
int c[15][105];
int main() {
  int n, m, k;
  cin >> n >> m >> k;
  for (int i = 0; i < n; i++) {
    string nm;
    cin >> nm;
    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> > q;
      for (int p = 0; p < m; p++)
        q.push_back(make_pair(b[i][p] - a[j][p], c[j][p]));
      sort(q.begin(), q.end());
      reverse(q.begin(), q.end());
      int rest = k;
      int res = 0, sale = 0;
      for (int p = 0; p < m && rest; p++) {
        if (q[p].first < 0) break;
        sale = min(rest, q[p].second);
        res += q[p].first * sale;
        rest -= sale;
      }
      ans = max(ans, res);
    }
  cout << ans << endl;
  return 0;
}
