#include <bits/stdc++.h>
using namespace std;
int a[11][111], b[11][111], c[11][111];
vector<pair<int, int> > d;
int main(void) {
  int i, j, l, t, s, n, m, k, res, tres;
  cin >> n >> m >> k;
  res = 0;
  for (i = 0; i < n; i++) {
    scanf(" %*s");
    for (j = 0; j < m; j++) cin >> a[i][j] >> b[i][j] >> c[i][j];
  }
  for (i = 0; i < n; i++)
    for (j = 0; j < n; j++)
      if (i != j) {
        tres = 0;
        d.clear();
        for (l = 0; l < m; l++) {
          d.push_back(make_pair(max(-a[i][l] + b[j][l], 0), c[i][l]));
        }
        sort(d.begin(), d.end());
        t = k;
        for (l = m - 1; l >= 0; l--) {
          s = min(d[l].second, t);
          tres += d[l].first * s;
          t -= s;
        }
        if (res < tres) res = tres;
      }
  cout << res << endl;
  return 0;
}
