#include <bits/stdc++.h>
using namespace std;
const int MAX_BUF_SIZE = 16384;
char BUFOR[MAX_BUF_SIZE];
int BUF_SIZE, BUF_POS;
char ZZZ;
int _MINUS;
const int MXN = 110;
const int C = 262144;
const int INF = 1000000001;
int n, m, k;
string str[MXN];
int a[MXN][MXN], b[MXN][MXN], c[MXN][MXN];
int main() {
  cin >> n >> m >> k;
  for (int i = (1); i <= (n); i++) {
    cin >> str[i];
    for (int j = (1); j <= (m); j++)
      scanf("%d %d %d", &a[i][j], &b[i][j], &c[i][j]);
  }
  int res = 0;
  for (int i = (1); i <= (n); i++)
    for (int j = (1); j <= (n); j++)
      if (i != j) {
        vector<pair<int, int> > vec;
        for (int o = (1); o <= (m); o++)
          vec.push_back(make_pair(b[j][o] - a[i][o], c[i][o]));
        sort((vec).begin(), (vec).end());
        int resTmp = 0;
        int cnt = k;
        for (int o = ((int)(vec).size() - 1); o >= (0); o--) {
          pair<int, int> p1 = vec[o];
          if (p1.first > 0) {
            while (p1.second && cnt > 0) {
              p1.second--;
              resTmp += p1.first;
              cnt--;
            }
          }
        }
        res = max(res, resTmp);
      }
  printf("%d\n", res);
  return 0;
}
