#include <bits/stdc++.h>
using namespace std;
double const pi = 3.1415926536;
int main() {
  int n, m, k;
  cin >> n >> m >> k;
  string s[n];
  int a[n][m], b[n][m], c[n][m];
  for (int i = 0; i < n; i++) {
    cin >> s[i];
    for (int j = 0; j < m; j++) cin >> a[i][j] >> b[i][j] >> c[i][j];
  }
  int max = 0;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) {
      if (i != j) {
        int h = 0;
        int p[m], r[m];
        for (int l = 0; l < m; l++) {
          p[l] = b[j][l] - a[i][l];
          r[l] = c[i][l];
        }
        for (int l = 0; l < m; l++)
          for (int u = l + 1; u < m; u++) {
            if (p[l] < p[u]) {
              swap(p[l], p[u]);
              swap(r[l], r[u]);
            }
          }
        int o = k;
        for (int l = 0; l < m; l++) {
          if (o > 0 && p[l] > 0) {
            h += p[l] * min(r[l], o);
            o -= r[l];
          }
        }
        if (h > max) max = h;
      }
    }
  cout << max;
}
