#include <bits/stdc++.h>
using namespace std;
int n, m, k;
int a[15][110], b[15][110], c[15][110];
char buf[15];
int calc(int p, int q) {
  static pair<int, int> d[110];
  int cnt = k, res = 0;
  for (int i = 1; i <= m; i++)
    d[i].first = b[q][i] - a[p][i], d[i].second = c[p][i];
  sort(d + 1, d + m + 1, greater<pair<int, int> >());
  for (int i = 1; i <= m && d[i].first > 0; i++) {
    if (cnt <= d[i].second) {
      res += d[i].first * cnt;
      break;
    }
    res += d[i].first * d[i].second;
    cnt -= d[i].second;
  }
  return res;
}
int main() {
  scanf("%d%d%d", &n, &m, &k);
  for (int i = 1; i <= n; i++) {
    scanf("%s", buf);
    for (int j = 1; j <= m; j++) scanf("%d%d%d", &a[i][j], &b[i][j], &c[i][j]);
  }
  int ans = 0;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++)
      if (i != j) ans = max(ans, calc(i, j));
  printf("%d\n", ans);
  return 0;
}
