#include <bits/stdc++.h>
using namespace std;
const int maxn = 110;
struct piece {
  int buy;
  int cnt;
  int sell;
  int num;
};
piece a[maxn][maxn];
int sell[maxn][maxn];
bool operator<(const piece& a, const piece& b) { return a.buy > b.buy; }
int main() {
  int n, m, k;
  int i, j;
  cin >> n >> m >> k;
  string s;
  int t;
  for (t = 0; t < n; ++t) {
    cin >> s;
    for (i = 0; i < m; ++i) {
      cin >> a[t][i].buy >> a[t][i].sell >> a[t][i].cnt;
      a[t][i].num = i;
      sell[t][i] = a[t][i].sell;
    }
  }
  vector<pair<int, int> > v(m);
  int ans = 0;
  int p;
  int tb;
  int tmp;
  for (i = 0; i < n; ++i)
    for (j = 0; j < n; ++j)
      if (i != j) {
        for (t = 0; t < m; ++t) v[t] = make_pair(a[j][t].sell - a[i][t].buy, t);
        sort(v.begin(), v.end());
        p = k;
        tmp = 0;
        for (t = m - 1; t >= 0 && p > 0; --t)
          if (v[t].first > 0) {
            tb = min(p, a[i][v[t].second].cnt);
            tmp += tb * v[t].first;
            p -= tb;
          } else
            break;
        ans = max(ans, tmp);
      }
  cout << ans << endl;
  return 0;
}
