#include <bits/stdc++.h>
using namespace std;
template <typename T, typename TT>
ostream &operator<<(ostream &s, pair<T, TT> t) {
  return s << "(" << t.first << "," << t.second << ")";
}
template <typename T>
ostream &operator<<(ostream &s, vector<T> t) {
  s << "{";
  for (int i = 0; i < t.size(); i++)
    s << t[i] << (i == t.size() - 1 ? "" : ",");
  return s << "}" << endl;
}
int a[200][200], b[200][200], c[200][200];
int main() {
  ios_base::sync_with_stdio(0);
  int n, m, k;
  cin >> n >> m >> k;
  int best = 0;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    for (int j = 0; j < m; j++) cin >> a[i][j] >> b[i][j] >> c[i][j];
  }
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) {
      if (i == j) continue;
      vector<int> v;
      for (int f = 0; f < m; f++)
        for (int l = 0; l < c[i][f]; l++) {
          v.push_back(b[j][f] - a[i][f]);
        }
      sort((v).begin(), (v).end());
      reverse((v).begin(), (v).end());
      int wyn = 0;
      for (int f = 0; f < min(k, (int)v.size()); f++)
        if (v[f] >= 0) wyn += v[f];
      (best) = max((best), (wyn));
    }
  cout << best;
  return 0;
}
