#include <bits/stdc++.h>
using namespace std;
int A[(16)][(128)];
int B[(16)][(128)];
int C[(16)][(128)];
vector<pair<int, int> > v;
int n, m, k;
int solve(int p1, int p2) {
  int i;
  v.clear();
  for (i = 0; i < m; i++) {
    v.push_back(make_pair(-B[p2][i] + A[p1][i], i));
  }
  sort((v).begin(), (v).end());
  int cap = k;
  int resp = 0;
  for (i = 0; i < m; i++) {
    int lucro = -v[i].first;
    int ind = v[i].second;
    if (lucro <= 0) break;
    int levo = min(cap, C[p1][ind]);
    resp += levo * lucro;
    cap -= levo;
    if (cap == 0) break;
  }
  return resp;
}
int main() {
  int i, j;
  scanf("%d %d %d", &n, &m, &k);
  for (i = 0; i < n; i++) {
    scanf(" %*s");
    for (j = 0; j < m; j++) {
      int a, b, c;
      scanf(" %d %d %d", &a, &b, &c);
      A[i][j] = a;
      B[i][j] = b;
      C[i][j] = c;
    }
  }
  int resp = 0;
  for (i = 0; i < n; i++) {
    for (j = 0; j < n; j++) {
      if (j == i) continue;
      resp = max(resp, solve(i, j));
    }
  }
  printf("%d\n", resp);
}
