#include <bits/stdc++.h>
using namespace std;
int n, m, k;
int a[105][105], b[105][105], c[105][105], mx[105];
char s[105];
int gao(int p, int q) {
  vector<int> v;
  for (int j = 0; j < m; ++j)
    for (int i = 0; i < c[p][j]; ++i) v.push_back(b[q][j] - a[p][j]);
  sort(v.begin(), v.end());
  int ret = 0, cc = k;
  for (vector<int>::reverse_iterator it = v.rbegin(); it != v.rend(); ++it) {
    if (0 == cc || *it <= 0) break;
    --cc;
    ret += *it;
  }
  return ret;
}
int main() {
  scanf("%d %d %d", &n, &m, &k);
  for (int i = 0; i < n; ++i) {
    scanf("%s", s);
    for (int j = 0; j < m; ++j) {
      scanf("%d %d %d", &a[i][j], &b[i][j], &c[i][j]);
      mx[j] = max(mx[j], b[i][j]);
    }
  }
  int ans = 0;
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < n; ++j)
      if (i != j) ans = max(ans, gao(i, j));
  printf("%d\n", ans);
  return 0;
}
