#include <bits/stdc++.h>
using namespace std;
int N, M, K, Ans;
struct PRODUCT {
  int buy, sell, amt;
  bool operator<(const PRODUCT& p) const { return buy > p.buy; }
} product[2000];
PRODUCT P[2000];
void test(int Ni, int Nj) {
  for (int Mi = 0; Mi < M; Mi++) {
    P[Mi].buy = product[Ni * M + Mi].sell - product[Nj * M + Mi].buy;
    P[Mi].amt = product[Nj * M + Mi].amt;
  }
  sort(P, P + M);
  int Kp = K;
  int re = 0;
  for (int Mi = 0; Mi < M; Mi++) {
    if (P[Mi].buy < 0) break;
    int p = min(Kp, P[Mi].amt);
    Kp -= p;
    re += p * P[Mi].buy;
  }
  Ans = max(Ans, re);
}
int main() {
  scanf("%d %d %d", &N, &M, &K);
  for (int Ni = 0; Ni < N; Ni++) {
    scanf("%*s");
    for (int Mi = 0; Mi < M; Mi++) {
      scanf("%d", &product[Ni * M + Mi].buy);
      scanf("%d", &product[Ni * M + Mi].sell);
      scanf("%d", &product[Ni * M + Mi].amt);
    }
  }
  for (int Ni = 0; Ni < N; Ni++)
    for (int Nj = 0; Nj < N; Nj++) {
      if (Ni == Nj) continue;
      test(Ni, Nj);
    }
  printf("%d\n", Ans);
}
