#include <bits/stdc++.h>
using namespace std;
struct planet {
  int buy[111];
  int sell[111];
  int num[111];
} plan[11];
struct value {
  int val;
  int place;
} v[111];
bool cmp(struct value a, struct value b) { return a.val > b.val; }
int main() {
  int n, m, kk;
  cin >> n >> m >> kk;
  for (int i = 0; i < n; i++) {
    char c[122] = {0};
    scanf("%s", c);
    for (int j = 0; j < m; j++)
      cin >> plan[i].buy[j] >> plan[i].sell[j] >> plan[i].num[j];
  }
  int maxx = 0;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) {
      if (i == j) continue;
      for (int k = 0; k < m; k++)
        v[k].val = plan[j].sell[k] - plan[i].buy[k], v[k].place = k;
      sort(v, v + m, cmp);
      if (v[0].val < 0) continue;
      int sum = 0;
      int rest = kk;
      for (int k = 0; k < m; k++) {
        if (v[k].val < 0)
          break;
        else if (plan[i].num[v[k].place] >= rest) {
          sum += rest * (v[k].val);
          break;
        }
        sum += plan[i].num[v[k].place] * (v[k].val);
        rest -= plan[i].num[v[k].place];
      }
      maxx = max(maxx, sum);
    }
  cout << maxx << endl;
  return 0;
}
