#include <bits/stdc++.h>
using namespace std;
const int MAXN = 10;
const int MAXM = 100;
int a[MAXN][MAXM], b[MAXN][MAXM], c[MAXN][MAXM], diff[MAXM], n1[MAXM];
void sort(int *f1, int *f2, int N) {
  for (int i = 1; i < N; i++) {
    if (f1[i] < f1[i - 1]) {
      int tmp1 = f1[i];
      int tmp2 = f2[i];
      int j;
      for (j = i; j > 0 && f1[j - 1] > tmp1; j--) {
        f1[j] = f1[j - 1];
        f2[j] = f2[j - 1];
      }
      f1[j] = tmp1;
      f2[j] = tmp2;
    }
  }
}
int main(int argc, char const *argv[]) {
  int n, m, nk, so = 0;
  string nm;
  cin >> n >> m >> nk;
  for (int i = 0; i < (int)(n); ++i) {
    cin >> nm;
    for (int j = 0; j < (int)(m); ++j) {
      cin >> a[i][j] >> b[i][j] >> c[i][j];
    }
  }
  for (int i = 0; i < (int)(n); ++i)
    for (int j = 0; j < (int)(n); ++j)
      if (i != j) {
        for (int k = 0; k < (int)(m); ++k) {
          diff[k] = b[j][k] - a[i][k];
          n1[k] = c[i][k];
        }
        sort(diff, n1, m);
        int cs = 0, rk = nk;
        for (int ck = m - 1; ck >= 0 && diff[ck] > 0 && rk; ck--) {
          int bk = min(rk, n1[ck]);
          cs += diff[ck] * bk;
          rk -= bk;
        }
        if (cs > so) so = cs;
      }
  cout << so << endl;
  return 0;
}
