#include <bits/stdc++.h>
using namespace std;
int N, M, T;
char str[15];
int a[12][127][3];
int main() {
  int i, j, k;
  scanf("%d%d%d", &N, &M, &T);
  for (int ii = 1; ii <= N; ii++) {
    scanf("%s", str);
    for (i = 1; i <= M; i++)
      scanf("%d%d%d", &a[ii][i][0], &a[ii][i][1], &a[ii][i][2]);
  }
  vector<pair<int, int> > v;
  pair<int, int> pr;
  int ans = 0, s = 0, x;
  for (i = 1; i <= N; i++) {
    for (j = 1; j <= N; j++) {
      if (i == j) continue;
      for (k = 1; k <= M; k++) {
        pr.first = a[j][k][1] - a[i][k][0];
        pr.second = a[i][k][2];
        v.push_back(pr);
      }
      sort(v.begin(), v.end());
      x = T;
      s = 0;
      for (k = M - 1; k >= 0; k--) {
        if (v[k].first <= 0) break;
        if (v[k].second <= x) {
          s += (v[k].first * v[k].second);
          x -= v[k].second;
        } else {
          s += (v[k].first * x);
          x -= x;
          break;
        }
      }
      ans = max(ans, s);
      v.clear();
    }
  }
  printf("%d\n", ans);
  scanf(" ");
}
