#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n, m, k;
  cin >> n >> m >> k;
  struct Planet {
    vector<int> a, b, c;
  };
  vector<Planet> planet(n);
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    planet[i].a.resize(m);
    planet[i].b.resize(m);
    planet[i].c.resize(m);
    for (int j = 0; j < m; j++)
      cin >> planet[i].a[j] >> planet[i].b[j] >> planet[i].c[j];
  }
  int result = 0;
  for (int p1ind = 0; p1ind < n; p1ind++)
    for (int p2ind = 0; p2ind < n; p2ind++)
      if (p1ind != p2ind) {
        Planet &p1 = planet[p1ind], &p2 = planet[p2ind];
        vector<pair<int, int> > profit;
        for (int i = 0; i < m; i++)
          if (p1.a[i] < p2.b[i]) {
            profit.push_back({p2.b[i] - p1.a[i], p1.c[i]});
          }
        sort(profit.begin(), profit.end());
        reverse(profit.begin(), profit.end());
        int ck = k;
        int ret = 0;
        for (int i = 0; i < (int)profit.size() && ck > 0; i++) {
          int take = min(ck, profit[i].second);
          ret += profit[i].first * take;
          ck -= take;
        }
        result = max(result, ret);
      }
  cout << result << '\n';
  return 0;
}
