#include <bits/stdc++.h>
using namespace std;
const int DBG = 0, INF = int(1e9);
string toString(long long k) {
  stringstream ss;
  ss << k;
  string res;
  ss >> res;
  return res;
}
int toInt(string s) {
  stringstream ss;
  ss << s;
  int res;
  ss >> res;
  return res;
}
const int MAXN = 100;
int A[MAXN][MAXN], B[MAXN][MAXN], C[MAXN][MAXN];
int main() {
  ios_base::sync_with_stdio(0);
  cout.setf(ios::fixed);
  int n, m, k;
  cin >> n >> m >> k;
  for (int _n = (n), i = 0; i < _n; ++i) {
    string s;
    cin >> s;
    for (int _n = (m), j = 0; j < _n; ++j) cin >> A[i][j] >> B[i][j] >> C[i][j];
  }
  int res = 0;
  for (int _n = (n), a = 0; a < _n; ++a)
    for (int _n = (n), b = 0; b < _n; ++b)
      if (a != b) {
        vector<int> v;
        for (int _n = (m), j = 0; j < _n; ++j)
          for (int _n = (C[a][j]), c = 0; c < _n; ++c)
            v.push_back(max(B[b][j] - A[a][j], 0));
        sort(v.begin(), v.end());
        reverse(v.begin(), v.end());
        int sm = 0;
        for (int _n = (min(k, (int)v.size())), j = 0; j < _n; ++j) sm += v[j];
        res = max(res, sm);
      }
  cout << res << endl;
  return 0;
}
