#include <bits/stdc++.h>
using namespace std;
const int MAXN = 10, MAXM = 100;
int A[MAXN][MAXM], B[MAXN][MAXM], C[MAXN][MAXM];
int order[MAXM];
int ib, is;
bool cmp(int a, int b) { return B[is][a] - A[ib][a] > B[is][b] - A[ib][b]; }
int main() {
  int n, m, k, ans = 0, tmp;
  int cur_hold, nx, p;
  int i, j, id;
  scanf("%d%d%d", &n, &m, &k);
  for (i = 0; i < n; ++i) {
    scanf("%*s");
    for (j = 0; j < m; ++j) scanf("%d%d%d", A[i] + j, B[i] + j, C[i] + j);
  }
  for (ib = 0; ib < n; ++ib)
    for (is = 0; is < n; ++is)
      if (ib != is) {
        for (j = 0; j < m; ++j) order[j] = j;
        sort(order, order + m, cmp);
        for (tmp = cur_hold = j = 0; j < m; ++j) {
          id = order[j];
          if ((p = B[is][id] - A[ib][id]) > 0) {
            nx = min(C[ib][id], k - cur_hold);
            tmp += p * nx;
            cur_hold += nx;
          } else
            break;
        }
        if (ans < tmp) ans = tmp;
      }
  printf("%d\n", ans);
  return 0;
}
