#include <bits/stdc++.h>
using namespace std;
const int nmax = 105;
struct goods {
  int a, b, c;
} d[12][nmax];
int dif[nmax], ID[nmax];
int MAX = 0;
int comp(const void* a, const void* b) {
  int aa = *(int*)a, bb = *(int*)b;
  return -(dif[aa] - dif[bb]);
}
int main() {
  int n, m, i, k, j, p;
  string s;
  cin >> n >> m >> k;
  for (i = 0; i < n; i++) {
    cin >> s;
    for (j = 0; j < m; j++) {
      cin >> d[i][j].a >> d[i][j].b >> d[i][j].c;
    }
  }
  for (i = 0; i < n; i++) {
    for (j = 0; j < n; j++) {
      if (i == j) continue;
      for (p = 0; p < m; p++) {
        dif[p] = d[j][p].b - d[i][p].a;
        ID[p] = p;
      }
      qsort(ID, m, sizeof(int), comp);
      int cur = 0, has = k, take;
      for (p = 0; p < m; p++) {
        if (dif[ID[p]] <= 0) break;
        take = min(has, d[i][ID[p]].c);
        has -= take;
        cur += dif[ID[p]] * take;
        if (has == 0) break;
      }
      MAX = max(MAX, cur);
    }
  }
  cout << MAX;
  return 0;
}
