#include <bits/stdc++.h>
using namespace std;
int n, m, k;
struct good {
  int b;
  int a;
  int c;
  good(int a = 0, int b = 0, int c = 0) : a(a), b(b), c(c) {}
};
int maximize(const vector<good>& source, const vector<good>& dist) {
  int kk = k;
  vector<pair<int, int> > v;
  for (int i = 0; i < source.size(); ++i) {
    v.push_back(make_pair(-(dist[i].b - source[i].a), source[i].c));
  }
  sort(v.begin(), v.end());
  int res = 0;
  for (int i = 0; i < v.size() && kk > 0 && v[i].first < 0; ++i) {
    res += -v[i].first * (min(kk, v[i].second));
    kk -= v[i].second;
  }
  return res;
}
int main() {
  cin >> n >> m >> k;
  vector<vector<good> > v;
  string s;
  v.resize(n);
  for (int i = 0; i < n; ++i) {
    cin >> s;
    int a, b, c;
    for (int j = 0; j < m; ++j) {
      cin >> a >> b >> c;
      v[i].push_back(good(a, b, c));
    }
  }
  int res = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      if (i == j) continue;
      res = max(res, maximize(v[i], v[j]));
    }
  }
  cout << res;
}
