#include <bits/stdc++.h>
using namespace std;
const int DX[8] = {1, -1, 0, 0, 1, 1, -1, -1};
const int DY[8] = {0, 0, 1, -1, 1, -1, 1, -1};
const int intmax = 0x7fffffff;
const int mod = 1000000007;
int f[105];
int a[15][105], b[15][105], c[15][105];
int v[105], cc[105];
pair<int, int> p[105];
int n, m, nk;
int saya() {
  for (int i = 0; i < m; i++) p[i] = make_pair(v[i], cc[i]);
  sort(p, p + m, greater<pair<int, int> >());
  int tmpk = nk;
  int ans = 0;
  for (int i = 0; i < m; i++) {
    if (p[i].first <= 0) return ans;
    if (tmpk - p[i].second <= 0) {
      ans += tmpk * p[i].first;
      return ans;
    }
    ans += p[i].first * p[i].second;
    tmpk -= p[i].second;
  }
  return ans;
}
int main() {
  scanf("%d%d%d", &n, &m, &nk);
  for (int i = 0; i < n; i++) {
    scanf("%*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++) {
      if (i == j) continue;
      for (int k = 0; k < m; k++) v[k] = b[j][k] - a[i][k];
      for (int k = 0; k < m; k++) cc[k] = c[i][k];
      ans = max(saya(), ans);
    }
  printf("%d\n", ans);
}
