#include <bits/stdc++.h>
using namespace std;
int n, m, K;
int PD[1024][1024];
char nome[1024];
int a[1024][1024], b[1024][1024], c[1024][1024];
int I, J;
int calc(int item, int k) {
  if (item == m) return 0;
  int &pd = PD[item][k];
  if (pd != 0x3f3f3f3f) return pd;
  int maior = -0x3f3f3f3f;
  for (int i = 0; i <= c[I][item] and i <= k; i++) {
    int tt = i * (b[J][item] - a[I][item]) + calc(item + 1, k - i);
    if (tt > maior) maior = tt;
  }
  return pd = maior;
}
int main() {
  scanf("%d %d %d", &n, &m, &K);
  for (int i = 0; i < n; i++) {
    scanf("%s", nome);
    for (int j = 0; j < m; j++) scanf("%d %d %d", &a[i][j], &b[i][j], &c[i][j]);
  }
  int maior = 0;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++)
      if (i != j) {
        for (int k = 0; k < m; k++) memset(PD[k], 0x3f, (K + 2) * sizeof(int));
        I = i;
        J = j;
        int tt = calc(0, K);
        if (tt > maior) maior = tt;
      }
  printf("%d\n", maior);
  return 0;
}
