#include <bits/stdc++.h>
using namespace std;
int i, j, k, n, m, x, y, T, ans, mx, mi, cas, num, len;
bool flag;
int p, a[25][105], b[25][105], c[25][105];
char s[1000];
int dp[1005];
int main() {
  scanf("%d%d%d", &n, &m, &p);
  for (i = 1; i <= n; i++) {
    scanf("%s", s);
    for (j = 1; j <= m; j++) {
      scanf("%d%d%d", &a[i][j], &b[i][j], &c[i][j]);
    }
  }
  int v;
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= n; j++) {
      memset(dp, 0, sizeof(dp));
      for (x = 1; x <= m; x++) {
        for (v = p; v >= 0; v--) {
          for (num = 0; num <= c[i][x]; num++) {
            int pro = b[j][x] - a[i][x];
            if (v - num >= 0 && dp[v] < dp[v - num] + pro * num) {
              dp[v] = dp[v - num] + pro * num;
              ans = max(ans, dp[v]);
            } else if (v - num < 0)
              break;
          }
        }
      }
    }
  }
  printf("%d\n", ans);
  return 0;
}
