#include <bits/stdc++.h>
using namespace std;
const int N = 3010;
int a[11][110], b[11][110], c[11][110];
multiset<pair<int, int> >::iterator it;
int main() {
  int n, m, k;
  string s;
  cin >> n >> m >> k;
  for (int i = 0; i < n; i++) {
    cin >> s;
    for (int j = 0; j < m; j++) cin >> a[i][j] >> b[i][j] >> c[i][j];
  }
  int maxi = 0;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++)
      if (i != j) {
        int ost = k, cost = 0;
        multiset<pair<int, int> > s;
        for (int q = 0; q < m; q++)
          s.insert(make_pair(-(b[j][q] - a[i][q]), q));
        for (it = s.begin(); it != s.end(); it++) {
          int cur = -(it->first), p = it->second;
          int can = min(c[i][p], ost);
          if (cur < 0) break;
          cost += cur * can;
          ost -= can;
        }
        maxi = max(maxi, cost);
      }
  cout << maxi;
  return 0;
}
