#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:16777216")
using namespace std;
template <typename T>
inline bool remin(T& c, const T& n) {
  if (n < c) {
    c = n;
    return 1;
  }
  return 0;
}
template <typename T>
inline bool remax(T& c, const T& n) {
  if (c < n) {
    c = n;
    return 1;
  }
  return 0;
}
int _in;
int in() {
  scanf("%d", &_in);
  return _in;
}
char buf[1000];
struct record {
  int bid, ask, left;
} maj[10][100];
pair<int, int> goods[100];
int main() {
  int n, g, cap, i, j, k, profit = 0, take, earn, a;
  scanf("%d%d%d\n", &n, &g, &cap);
  for ((i) = (0); (i) < (n); ++(i)) {
    gets(buf);
    for ((j) = (0); (j) < (g); ++(j))
      scanf("%d%d%d\n", &maj[i][j].bid, &maj[i][j].ask, &maj[i][j].left);
  }
  for ((i) = (0); (i) < (n); ++(i))
    for ((j) = (0); (j) < (n); ++(j)) {
      if (i == j) continue;
      for ((k) = (0); (k) < (g); ++(k))
        goods[k] = pair<int, int>((maj[j][k].ask - maj[i][k].bid), k);
      sort(goods, goods + g, greater<pair<int, int> >());
      earn = 0;
      take = cap;
      for ((k) = (0); (k) < (g); ++(k))
        if (goods[k].first > 0) {
          a = min(take, maj[i][goods[k].second].left);
          take -= a;
          earn += goods[k].first * a;
        }
      remax(profit, earn);
    }
  printf("%d\n", profit);
  return 0;
}
