#include <bits/stdc++.h>
using namespace std;
long long int n, m, k, a[10][100], b[10][100], c[10][100], ans, t, r, ma;
pair<long long int, long long int> u[100];
pair<long long int, long long int> s;
string ss;
int main() {
  cin >> n >> m >> k;
  for (int i = 0; i < n; i++) {
    cin >> ss;
    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 = i + 1; j < n; j++) {
      for (int l = 0; l < m; l++) {
        u[l].first = b[j][l] - a[i][l];
        u[l].second = c[i][l];
      }
      sort(u, u + m);
      t = k;
      r = m - 1;
      ma = 0;
      while (t > 0 && u[r].first > 0) {
        if (u[r].second <= t) {
          t -= u[r].second;
          ma += u[r].first * u[r].second;
        } else {
          ma += u[r].first * t;
          t = 0;
        }
        r--;
      }
      if (ma > ans) {
        ans = ma;
      }
      for (int l = 0; l < m; l++) {
        u[l].first = b[i][l] - a[j][l];
        u[l].second = c[j][l];
      }
      sort(u, u + m);
      t = k;
      r = m - 1;
      ma = 0;
      while (t > 0 && u[r].first > 0) {
        if (u[r].second <= t) {
          t -= u[r].second;
          ma += u[r].first * u[r].second;
        } else {
          ma += u[r].first * t;
          t = 0;
        }
        r--;
      }
      if (ma > ans) {
        ans = ma;
      }
    }
  cout << ans;
  return 0;
}
