#include <bits/stdc++.h>
using namespace std;
const int MAXN = 11, MAXM = 110, MAXS = 20;
int v[MAXN][MAXM][3];
pair<int, int> r[MAXM];
char str[MAXS];
int main() {
  int N, M, K;
  scanf("%d%d%d", &N, &M, &K);
  for (int i = 0; i < N; i++) {
    scanf("%s", str);
    for (int j = 0; j < M; j++)
      for (int k = 0; k < 3; k++) scanf("%d", &v[i][j][k]);
  }
  int ans = 0, res;
  for (int i = 0; i < N; i++)
    for (int j = 0; j < N; j++)
      if (i != j) {
        for (int k = 0; k < M; k++)
          r[k].first = v[j][k][1] - v[i][k][0], r[k].second = k;
        sort(r, r + M);
        res = 0;
        int remain = K;
        for (int k = M - 1; k >= 0 && remain > 0; k--)
          if (r[k].first > 0) {
            res += min(remain, v[i][r[k].second][2]) * r[k].first;
            remain -= v[i][r[k].second][2];
          } else
            break;
        ans = max(ans, res);
      }
  printf("%d\n", ans);
  return 0;
}
