#include <bits/stdc++.h>
using namespace std;
int a[10][100], b[10][100], c[10][100];
int n, m, k;
struct Good {
  int st;
  int kol;
  Good(int st, int kol) : st(st), kol(kol) {}
};
bool operator<(Good g1, Good g2) { return g1.st < g2.st; }
int main() {
  scanf("%d%d%d", &n, &m, &k);
  string s;
  for (int i = 0; i < n; i++) {
    cin >> s;
    for (int j = 0; j < m; j++) scanf("%d%d%d", &a[i][j], &b[i][j], &c[i][j]);
  }
  int ans = 0;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) {
      vector<Good> v;
      for (int k = 0; k < m; k++)
        if (c[i][k] > 0 && a[i][k] < b[j][k])
          v.push_back(Good(b[j][k] - a[i][k], c[i][k]));
      sort(v.begin(), v.end());
      int ans1 = 0;
      int k1 = k;
      for (int i = (int)v.size() - 1; i >= 0; i--)
        if (v[i].kol >= k1) {
          ans1 += v[i].st * k1;
          break;
        } else {
          ans1 += v[i].st * v[i].kol;
          k1 -= v[i].kol;
        }
      if (ans < ans1) ans = ans1;
    }
  printf("%d\n", ans);
  return 0;
}
