#include <bits/stdc++.h>
using namespace std;
struct node {
  string str;
  int a[111];
  int b[111];
  int c[111];
} p[111];
struct nn {
  int dif;
  int num;
} tmp[111];
int n, m, c;
bool cmp(nn a, nn b) {
  if (a.dif != b.dif) return a.dif > b.dif;
  return a.num > b.num;
}
int main() {
  cin >> n >> m >> c;
  int i, j, k;
  for (i = 0; i < n; i++) {
    cin >> p[i].str;
    for (j = 0; j < m; j++) {
      cin >> p[i].a[j] >> p[i].b[j] >> p[i].c[j];
    }
  }
  long long ans = 0;
  for (i = 0; i < n; i++) {
    for (j = 0; j < n; j++) {
      if (i == j) continue;
      for (k = 0; k < m; k++) {
        tmp[k].dif = p[j].b[k] - p[i].a[k];
        tmp[k].num = p[i].c[k];
      }
      sort(tmp, tmp + m, cmp);
      int res = c;
      long long sum = 0;
      for (k = 0; k < m; k++) {
        if (tmp[k].dif <= 0) break;
        if (res <= tmp[k].num) {
          sum += (long long)(res)*tmp[k].dif;
          res = 0;
          break;
        }
        sum += (long long)tmp[k].num * tmp[k].dif;
        res -= tmp[k].num;
      }
      ans = max(ans, sum);
    }
  }
  cout << ans << endl;
  return 0;
}
