#include <bits/stdc++.h>
using namespace std;
struct t {
  int a, b, c;
};
struct delt {
  int delta, kol;
};
bool cmp(delt a, delt b) { return a.delta < b.delta; }
int main() {
  int n, m, k, i, j, l, ans = 0;
  cin >> n >> m >> k;
  string x;
  vector<vector<t> > tov(n, vector<t>(m));
  vector<delt> Delta(m);
  for (i = 0; i < n; i++) {
    cin >> x;
    for (j = 0; j < m; j++) cin >> tov[i][j].a >> tov[i][j].b >> tov[i][j].c;
  }
  for (i = 0; i < n; i++)
    for (j = 0; j < n; j++)
      if (j != i) {
        int CUR_ANS = 0;
        for (l = 0; l < m; l++) {
          Delta[l].delta = tov[i][l].a - tov[j][l].b;
          Delta[l].kol = tov[i][l].c;
        }
        sort(Delta.begin(), Delta.end(), &cmp);
        int CUR_K = k;
        for (l = 0; l < m && CUR_K > 0; l++) {
          if (Delta[l].delta > 0) break;
          int MAX_NUM_CUR = min(Delta[l].kol, CUR_K);
          CUR_ANS += MAX_NUM_CUR * (-Delta[l].delta);
          CUR_K -= MAX_NUM_CUR;
        }
        if (CUR_ANS > ans) ans = CUR_ANS;
      }
  cout << ans;
}
