#include <bits/stdc++.h>
using namespace std;
const int MAXINT = 0x7fffffff;
int n, m, k, a[15][105][5];
vector<pair<int, int> > res;
int ans;
int main() {
  scanf("%d %d %d\n", &n, &m, &k);
  for (int i = 1; i <= n; ++i) {
    string tt;
    getline(cin, tt);
    for (int j = 1; j <= m; ++j)
      for (int tt = 1; tt <= 3; ++tt) scanf("%d", &a[i][j][tt]);
    scanf("\n");
  }
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= n; ++j)
      if (i != j) {
        int pf = 0, cap = k;
        vector<pair<int, int> > res;
        for (int t = 1; t <= m; ++t)
          if (a[i][t][1] < a[j][t][2] && a[i][t][3] > 0)
            res.push_back(pair<int, int>(a[j][t][2] - a[i][t][1], a[i][t][3]));
        sort(res.begin(), res.end());
        for (int t = res.size() - 1; t >= 0; --t) {
          int num = min(cap, res[t].second);
          pf += num * res[t].first;
          cap -= num;
          if (cap == 0) {
            ans = max(ans, pf);
            break;
          }
        }
        ans = max(ans, pf);
      }
  cout << ans << endl;
}
