#include <bits/stdc++.h>
using namespace std;
const int PlanetSIZE = 15, ProductSIZE = 110, NameSIZE = 15;
struct product {
  int bay, sell, number;
};
struct planet {
  char name[NameSIZE];
  product products[ProductSIZE];
} A[PlanetSIZE];
int R[PlanetSIZE][PlanetSIZE], B[ProductSIZE][2], Bp;
int vs(const void *a, const void *b) {
  if (*(int *)a == *(int *)b)
    return 0;
  else if (*(int *)a < *(int *)b)
    return 1;
  else
    return -1;
}
int main() {
  int N, M, K;
  cin >> N >> M >> K;
  for (int i = 0; i != N; i++) {
    cin >> A[i].name;
    for (int j = 0; j != M; j++)
      cin >> A[i].products[j].bay >> A[i].products[j].sell >>
          A[i].products[j].number;
  }
  for (int i = 0; i != N; i++)
    for (int j = 0; j != N; j++)
      if (i != j) {
        for (int k = 0; k != M; k++)
          B[k][0] = A[j].products[k].sell - A[i].products[k].bay,
          B[k][1] = A[i].products[k].number;
        qsort(B, M, sizeof(int) * 2, vs);
        int Kr = K, r = 0, k = 0;
        while (K && k != M)
          if (B[k][0] < 0)
            break;
          else if (B[k][1] <= K)
            r += B[k][0] * B[k][1], K -= B[k][1], k++;
          else
            r += B[k][0] * K, K = 0, k++;
        R[i][j] = r;
        K = Kr;
      }
  int ans = 0;
  for (int i = 0; i != N; i++)
    for (int j = 0; j != N; j++) {
      if (ans < R[i][j]) ans = R[i][j];
    }
  cout << ans;
  return 0;
}
