#include <bits/stdc++.h>
using namespace std;
void fast_stream() { std::ios_base::sync_with_stdio(0); }
int n, m, K;
int a[11][101];
int b[11][101];
int c[11][101];
void solve() {
  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];
  }
  int res = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (i == j) continue;
      priority_queue<int> pq;
      for (int k = 0; k < m; k++) {
        for (int l = 0; l < c[i][k]; l++) {
          pq.push(b[j][k] - a[i][k]);
        }
      }
      int a = 0;
      for (int k = 0; k < K; k++) {
        if (pq.empty() || pq.top() <= 0) break;
        int p = pq.top();
        pq.pop();
        a += p;
      }
      res = max(res, a);
    }
  }
  cout << res << endl;
}
int main() {
  solve();
  return 0;
}
