#include <bits/stdc++.h>
int n, m, k;
int a[15][110], b[15][110], c[15][110];
bool vis[110];
char ch[15];
int max(int x, int y) { return x > y ? x : y; }
int min(int x, int y) { return x < y ? x : y; }
int solve(int s, int t) {
  memset(vis, 0, sizeof(vis));
  int rest = k, ans = 0;
  while (rest > 0) {
    bool fl = 1;
    int mx = -1, pos;
    for (int i = 1; i <= m; i++)
      if (!vis[i])
        if (b[t][i] - a[s][i] > mx) {
          fl = 0;
          pos = i;
          mx = b[t][i] - a[s][i];
        }
    if (fl) break;
    int num = min(rest, c[s][pos]);
    rest -= num;
    ans += num * mx;
    vis[pos] = 1;
  }
  return ans;
}
int main() {
  scanf("%d%d%d", &n, &m, &k);
  for (int i = 1; i <= n; i++) {
    scanf("%s", ch);
    for (int j = 1; j <= m; j++) scanf("%d%d%d", &a[i][j], &b[i][j], &c[i][j]);
  }
  int ans = -1;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++) ans = max(ans, solve(i, j));
  printf("%d\n", ans);
  return 0;
}
