#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 10;
const int MAX_M = 100;
char ss[MAX_N][16];
int as[MAX_N][MAX_M], bs[MAX_N][MAX_M], cs[MAX_N][MAX_M];
pair<int, int> ps[MAX_M];
int main() {
  int n, m, k;
  scanf("%d%d%d", &n, &m, &k);
  for (int i = 0; i < n; i++) {
    scanf("%s", ss[i]);
    for (int j = 0; j < m; j++)
      scanf("%d%d%d", as[i] + j, bs[i] + j, cs[i] + j);
  }
  int maxp = 0;
  for (int i0 = 0; i0 < n; i0++)
    for (int i1 = 0; i1 < n; i1++)
      if (i0 != i1) {
        for (int j = 0; j < m; j++)
          ps[j] = pair<int, int>(bs[i1][j] - as[i0][j], cs[i0][j]);
        sort(ps, ps + m);
        int p = 0;
        for (int j = m - 1, r = k; j >= 0 && r > 0; j--) {
          int pj = ps[j].first, cj = ps[j].second;
          if (pj <= 0) break;
          int d = min(r, cj);
          p += pj * d;
          r -= d;
        }
        if (maxp < p) maxp = p;
      }
  printf("%d\n", maxp);
  return 0;
}
