#include <bits/stdc++.h>
using namespace std;
int Max(int a, int b) { return (((b - a) >> (32 - 1)) & (a ^ b)) ^ b; }
int Min(int a, int b) { return (((b - a) >> (32 - 1)) & (a ^ b)) ^ a; }
long long GCD(long long a, long long b) { return b != 0 ? GCD(b, a % b) : a; }
long long LCM(long long a, long long b) { return a * (b / GCD(a, b)); }
long long Pow(long long n, long long e) {
  if (e == 0) return 1;
  if (e == 1)
    return n;
  else if (e & 1) {
    long long t = Pow(n, e / 2);
    return n * t * t;
  } else {
    long long t = Pow(n, e / 2);
    return t * t;
  }
}
const int MAX_N = 15;
const int MAX_M = 105;
int buy[MAX_N][MAX_M];
int sell[MAX_N][MAX_M];
int cnt[MAX_N][MAX_M];
bool Comp(const pair<int, int>& a, const pair<int, int>& b) {
  return a.first > b.first;
}
int main() {
  int N, M, K;
  scanf("%d %d %d", &N, &M, &K);
  for (int i = 0, max_ = (N); i < max_; ++i) {
    string s;
    cin >> s;
    for (int j = 0, max_ = (M); j < max_; ++j)
      scanf("%d %d %d", &buy[i][j], &sell[i][j], &cnt[i][j]);
  }
  int res = 0;
  for (int i = 0, max_ = (N); i < max_; ++i)
    for (int j = 0, max_ = (N); j < max_; ++j) {
      if (i == j) continue;
      int rem = K, r = 0;
      vector<pair<int, int> > v;
      for (int k = 0, max_ = (M); k < max_; ++k)
        v.push_back(make_pair(sell[j][k] - buy[i][k], k));
      sort((v).begin(), (v).end(), Comp);
      for (int k = 0, max_ = (M); k < max_; ++k) {
        if (rem == 0 || v[k].first <= 0) break;
        int b = min(rem, cnt[i][v[k].second]);
        rem -= b;
        r += b * v[k].first;
      }
      res = max(res, r);
    }
  printf("%d\n", res);
  return 0;
}
