#include <bits/stdc++.h>
using namespace std;
bool cmp(pair<int, int> x, pair<int, int> y) { return x.first > y.first; }
int main() {
  int n, m, k, buy[15][105], sell[15][105], cap[15][105], maxsell[105], res;
  char tmp[105];
  while (scanf("%d %d %d", &n, &m, &k) != EOF) {
    res = 0;
    for (int i = 0; i < n; i++) {
      scanf("%s", tmp);
      for (int j = 0; j < m; j++) {
        scanf("%d %d %d", &buy[i][j], &sell[i][j], &cap[i][j]);
      }
    }
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        if (i != j) {
          vector<pair<int, int> > vec;
          for (int l = 0; l < m; l++) {
            vec.push_back(make_pair(sell[j][l] - buy[i][l], cap[i][l]));
          }
          sort(vec.begin(), vec.end(), cmp);
          int sum = 0, sisa = k;
          for (int l = 0; l < vec.size(); l++) {
            if (vec[l].first <= 0 || sisa <= 0) break;
            sum = sum + (vec[l].first * min(sisa, vec[l].second));
            sisa -= min(sisa, vec[l].second);
          }
          res = max(res, sum);
        }
      }
    }
    printf("%d\n", res);
  }
  return 0;
}
