#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:16777216")
using namespace std;
string names[11];
int a[11][101];
int b[11][101];
int c[11][101];
int main(int argc, char **argv) {
  int n, m, k;
  vector<pair<int, int> > r;
  scanf("%d %d %d", &n, &m, &k);
  for (int i = 0; i < n; i++) {
    cin >> names[i];
    for (int j = 0; j < m; j++) {
      scanf("%d %d %d", &a[i][j], &b[i][j], &c[i][j]);
    }
  }
  int ans = 0;
  for (int i1 = 0; i1 < n; i1++)
    for (int i2 = 0; i2 < n; i2++) {
      int cost = 0;
      r.clear();
      for (int l = 0; l < m; l++)
        if (b[i2][l] - a[i1][l] > 0) {
          r.push_back(make_pair(b[i2][l] - a[i1][l], c[i1][l]));
        }
      sort(r.begin(), r.end());
      int ck = 0;
      for (int i = r.size(); i--;) {
        int d = min(r[i].second, k - ck);
        cost += r[i].first * d;
        ck += d;
      }
      if (cost > ans) {
        ans = cost;
      }
    }
  cout << ans << endl;
  return 0;
}
