#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, k;
  int a[200][200], b[200][200], c[200][200];
  int ans = 0;
  cin >> n >> m >> k;
  for (int i = 1; i <= n; i++) {
    string str;
    cin >> str;
    for (int j = 1; j <= m; j++) cin >> a[i][j] >> b[i][j] >> c[i][j];
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      int tmp = 0;
      int tk = k;
      if (i != j) {
        int w[200], v[200];
        for (int l = 1; l <= m; l++) {
          w[l] = b[j][l] - a[i][l];
          v[l] = c[i][l];
        }
        for (int l = 1; l <= m; l++) {
          for (int p = l + 1; p <= m; p++) {
            if (w[l] < w[p]) {
              swap(w[l], w[p]);
              swap(v[l], v[p]);
            }
          }
        }
        for (int l = 1; l <= m; l++) {
          if (w[l] < 0) break;
          if (tk >= v[l]) {
            tk -= v[l];
            tmp += w[l] * v[l];
          } else {
            tmp += w[l] * tk;
            break;
          }
        }
        if (tmp > ans) ans = tmp;
      }
    }
  }
  cout << ans;
  return 0;
}
