#include <bits/stdc++.h>
using namespace std;
int a[12][111];
int b[12][111];
int c[12][111];
pair<int, int> diff[111];
string s;
int main() {
  int n, m, k;
  cin >> n >> m >> k;
  for (int i = 0; i < n; i++) {
    cin >> s;
    for (int j = 0; j < m; j++) {
      cin >> a[i][j] >> b[i][j] >> c[i][j];
    }
  }
  int rez = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (i == j) continue;
      for (int z = 0; z < m; z++) {
        diff[z].first = b[j][z] - a[i][z];
        diff[z].second = z;
      }
      sort(&diff[0], &diff[m]);
      int sum = 0;
      int left = k;
      for (int z = m - 1; z >= 0 && left > 0; z--) {
        if (diff[z].first > 0) {
          int cnt = min(left, c[i][diff[z].second]);
          sum += cnt * diff[z].first;
          left -= cnt;
        }
      }
      rez = max(rez, sum);
    }
  }
  cout << rez << endl;
  return 0;
}
