#include <bits/stdc++.h>
using namespace std;
const int Maxn = 100007;
int n, m, k;
int a[17][107], b[17][107], c[17][107];
int zh[17][17][107];
pair<int, int> srt[17][17][107];
string EATER;
bool CdDx(pair<int, int> a, pair<int, int> b) { return a > b; }
int main() {
  scanf("%d%d%d", &n, &m, &k);
  getline(cin, EATER);
  for (int i = 0; i < n; i++) {
    getline(cin, EATER);
    for (int j = 0; j < m; j++) scanf("%d%d%d", &a[i][j], &b[i][j], &c[i][j]);
    getline(cin, EATER);
  }
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++)
      for (int k = 0; k < m; k++) {
        zh[i][j][k] = b[j][k] - a[i][k];
        srt[i][j][k] = make_pair(zh[i][j][k], c[i][k]);
      }
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) sort(srt[i][j], srt[i][j] + m, CdDx);
  int ans = 0;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) {
      int kk = k, ans2 = 0;
      for (int x = 0; x < m; x++) {
        ans2 += min(kk, srt[i][j][x].second) * srt[i][j][x].first;
        kk -= min(kk, srt[i][j][x].second);
        ans = max(ans, ans2);
      }
    }
  printf("%d\n", ans);
  return getchar(), getchar(), 0;
  ;
}
