#include <bits/stdc++.h>
using namespace std;
int a[11][110], b[11][110], c[11][110];
int price[110], num[110], run;
int ans;
void SORT() {
  for (int i = 0; i < run; i++) {
    for (int j = i + 1; j < run; j++) {
      if (price[i] < price[j]) {
        swap(price[i], price[j]);
        swap(num[i], num[j]);
      }
    }
  }
}
int main() {
  int n, m, k, temp, r, p;
  char s[15];
  cin >> n >> m >> k;
  for (int i = 0; i < n; i++) {
    cin >> s;
    for (int j = 0; j < m; j++) {
      cin >> a[i][j] >> b[i][j] >> c[i][j];
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (i != j) {
        run = 0;
        for (int l = 0; l < m; l++) {
          price[run] = b[j][l] - a[i][l];
          num[run] = c[i][l];
          run++;
        }
        SORT();
        temp = 0;
        r = 0;
        p = k;
        while (p > 0 && r < run && price[r] > 0) {
          if (p >= num[r]) {
            p -= num[r];
            temp += price[r] * num[r];
            r++;
          } else {
            temp += price[r] * p;
            p = 0;
          }
        }
        if (temp > ans) ans = temp;
      }
    }
  }
  cout << ans << endl;
  scanf(" ");
}
