#include <bits/stdc++.h>
using namespace std;
const int N = 15, M = 1005;
struct Gift {
  int buy, sell, num;
  Gift(int b = 0, int s = 0, int n = 0) : buy(b), sell(s), num(n) {}
} gift[N][M];
struct SS {
  int get, num;
  friend bool operator<(const SS& a, const SS& b) { return a.get < b.get; }
} ss[M];
char buf[M];
int main() {
  int n, m, k, ans = 0;
  scanf("%d%d%d", &n, &m, &k);
  for (int i = 0; i < n; i++) {
    scanf("%s", buf);
    for (int j = 0; j < m; j++)
      scanf("%d%d%d", &gift[i][j].buy, &gift[i][j].sell, &gift[i][j].num);
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (i == j) continue;
      for (int k = 0; k < m; k++) {
        ss[k].get = gift[i][k].buy - gift[j][k].sell;
        ss[k].num = gift[i][k].num;
      }
      sort(ss, ss + m);
      int tmp = k, sum = 0;
      for (int k = 0; k < m && tmp; k++) {
        if (ss[k].get >= 0) break;
        int use = (tmp < ss[k].num ? tmp : ss[k].num);
        sum += use * ss[k].get;
        tmp -= use;
      }
      ans = (ans < sum ? ans : sum);
    }
  }
  printf("%d\n", -ans);
  return 0;
}
