#include <bits/stdc++.h>
using namespace std;
const int inf = 0x7fffffff;
const int Size = 1000 * 1000 + 1;
char buffer[Size];
int solution(int nTest) {
  int n, m, K;
  scanf("%d%d%d", &n, &m, &K);
  vector<string> name;
  vector<vector<int> > a, b, c;
  for (int i = 0; i < n; i++) {
    scanf("%s", buffer);
    name.push_back(buffer);
    int ta, tb, tc;
    vector<int> va, vb, vc;
    for (int j = 0; j < m; j++) {
      scanf("%d%d%d", &ta, &tb, &tc);
      va.push_back(ta);
      vb.push_back(tb);
      vc.push_back(tc);
    }
    a.push_back(va);
    b.push_back(vb);
    c.push_back(vc);
  }
  int res = 0;
  for (int i = 0; i < n; i++) {
    for (int k = 0; k < n; k++) {
      int t = K;
      vector<pair<int, int> > v;
      for (int j = 0; j < m; j++) {
        v.push_back(make_pair(b[k][j] - a[i][j], j));
      }
      sort(v.begin(), v.end());
      reverse(v.begin(), v.end());
      int sum = 0;
      for (int j = 0; j < m; j++) {
        if (v[j].first >= 0) {
          int ct = c[i][v[j].second];
          if (t >= ct) {
            sum += ct * v[j].first;
            t -= ct;
          } else {
            sum += t * v[j].first;
            t = 0;
          }
        }
      }
      res = max(res, sum);
    }
  }
  printf("%d\n", res);
  return 0;
}
int main() {
  if (0) {
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
  }
  int i = 0, n = 99999;
  while (i < n && solution(i)) {
    i++;
  }
  return 0;
}
