#include <bits/stdc++.h>
using namespace std;
const int N = 105;
int n, m, k, a[N][N], b[N][N], c[N][N], ans;
pair<int, int> buy[N];
int main() {
  cin >> n >> m >> k;
  for (int i = 0; i < n; i++) {
    string name;
    cin >> name;
    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) {
        for (int t = 0; t < m; t++)
          buy[t] = make_pair(b[j][t] - a[i][t], c[i][t]);
        sort(buy, buy + m);
        reverse(buy, buy + m);
        int rest = k, sum = 0;
        for (int t = 0; t < m; t++) {
          if (buy[t].first < 0) break;
          if (buy[t].second > rest) buy[t].second = rest;
          rest -= buy[t].second;
          sum += buy[t].first * buy[t].second;
          if (!rest) break;
        }
        if (sum > ans) ans = sum;
      }
  cout << ans << endl;
  return 0;
}
