#include <bits/stdc++.h>
struct node {
  int buy, sel, san;
};
int n, m, k;
node a[20][200];
int comp(void const *x, void const *y) {
  node q = *(node *)x;
  node w = *(node *)y;
  if (w.buy > q.buy) return 1;
  return -1;
}
int has(int x, int y) {
  node b[200];
  int sum = 0;
  for (int i = 0; i < m; i++) {
    b[i].buy = a[y][i].sel - a[x][i].buy;
    b[i].san = a[x][i].san;
  }
  qsort(b, m, sizeof(node), comp);
  int p = 0, i = 0;
  while (k > p && i < m) {
    if (b[i].buy < 0) break;
    p += b[i].san;
    sum += (b[i].buy * b[i].san);
    i++;
  }
  if (p > k) sum -= (p - k) * b[i - 1].buy;
  return sum;
}
int main() {
  scanf("%d %d %d", &n, &m, &k);
  for (int i = 0; i < n; i++) {
    char qwerty[20];
    scanf("%s", qwerty);
    for (int o = 0; o < m; o++)
      scanf("%d %d %d", &a[i][o].buy, &a[i][o].sel, &a[i][o].san);
  }
  int mx1 = 0;
  for (int i = 0; i < n; i++)
    for (int o = 0; o < n; o++) {
      int t = has(i, o);
      if (mx1 < t) mx1 = t;
    }
  printf("%d", mx1);
  return 0;
}
