#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, k;
  string s;
  int x;
  cin >> n >> m >> k;
  int a[n][m];
  int b[n][m];
  int c[n][m];
  for (int i = 0; i < n; i++) {
    cin >> s;
    for (int j = 0; j < m; j++) {
      cin >> x;
      a[i][j] = x;
      cin >> x;
      b[i][j] = x;
      cin >> x;
      c[i][j] = x;
    }
  }
  int sum_max = 0;
  int sum;
  vector<pair<int, int> > abc;
  abc.reserve(m);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (i == j) continue;
      sum = 0;
      abc.clear();
      for (int ii = 0; ii < m; ii++) {
        abc.push_back(make_pair(b[j][ii] - a[i][ii], c[i][ii]));
      }
      sort(abc.begin(), abc.end());
      int left = k;
      for (int ii = m - 1; ii >= 0 && left > 0; ii--) {
        int d = min(left, abc[ii].second);
        if (abc[ii].first > 0) {
          sum += d * abc[ii].first;
          left -= d;
        }
      }
      if (sum > sum_max) {
        sum_max = sum;
      }
    }
  }
  cout << sum_max << endl;
  return 0;
}
