#include <bits/stdc++.h>
using namespace std;
int a[110][110], b[110][110], q[110][110];
pair<int, int> ls[110];
int main() {
  int n, m, k;
  scanf("%d %d %d", &n, &m, &k);
  for (int i = 0; i < n; i++) {
    scanf("%*s");
    for (int j = 0; j < m; j++) scanf("%d %d %d", &a[i][j], &b[i][j], &q[i][j]);
  }
  int rsp = 0;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) {
      for (int z = 0; z < m; z++) {
        ls[z] = make_pair(a[i][z] - b[j][z], q[i][z]);
      }
      sort(ls, ls + m);
      int w = k;
      int tmp = 0;
      for (int z = 0; z < m; z++) {
        tmp += max(-ls[z].first, 0) * min(w, ls[z].second);
        w = w - min(w, ls[z].second);
      }
      rsp = max(rsp, tmp);
    }
  printf("%d\n", rsp);
  return 0;
}
