#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  int K;
  int cost[11][1100];
  int sell[11][1100];
  int remain[11][1100];
  int value[1100];
  int f[1100];
  scanf("%d%d%d", &n, &m, &K);
  getchar();
  int i;
  int j;
  char name[11][15];
  for (i = 1; i <= n; i++) {
    scanf("%s", name[i]);
    for (int j = 1; j <= m; j++) {
      scanf("%d%d%d", &cost[i][j], &sell[i][j], &remain[i][j]);
    }
    getchar();
  }
  int ans = 0;
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= n; j++) {
      if (i == j) continue;
      for (int k = 1; k <= m; k++) {
        value[k] = sell[j][k] - cost[i][k];
        f[k] = remain[i][k];
      }
      for (int k = 1; k < m; k++)
        for (int l = k + 1; l <= m; l++)
          if (value[k] < value[l])
            value[k] ^= value[l] ^= value[k] ^= value[l],
                f[k] ^= f[l] ^= f[k] ^= f[l];
      int s = K;
      int temp = 0;
      for (int k = 1; k <= m; k++) {
        if (s >= f[k]) {
          if (value[k] > 0) {
            temp += f[k] * value[k];
            s -= f[k];
          } else
            break;
        } else {
          if (value[k] > 0) {
            temp += s * value[k];
          }
          break;
        }
      }
      if (ans < temp) ans = temp;
    }
  }
  printf("%d\n", ans);
  return 0;
}
