#include <bits/stdc++.h>
using namespace std;
template <class T>
inline void read(T& x) {
  bool fu = 0;
  char c;
  for (c = getchar(); c <= 32; c = getchar())
    ;
  if (c == '-') fu = 1, c = getchar();
  for (x = 0; c > 32; c = getchar()) x = x * 10 + c - '0';
  if (fu) x = -x;
};
template <class T>
inline void read(T& x, T& y) {
  read(x);
  read(y);
}
template <class T>
inline void read(T& x, T& y, T& z) {
  read(x);
  read(y);
  read(z);
}
inline char getc() {
  char c;
  for (c = getchar(); c <= 32; c = getchar())
    ;
  return c;
}
int n, m, K, i, j, l, p;
long long best, res;
struct arr {
  int a[110], b[110], c[110];
} a[11];
char s[11111];
pair<long long, long long> t[111];
long long calc(arr x, arr y) {
  int i, j, g = 0, k = K;
  for (i = 1; i <= m; i++)
    if (x.a[i] < y.b[i] && x.c[i] > 0)
      t[++g] = make_pair(y.b[i] - x.a[i], x.c[i]);
  sort(t + 1, t + 1 + g);
  reverse(t + 1, t + 1 + g);
  long long ans = 0;
  for (i = 1; i <= g; i++) {
    if (k == 0) break;
    k--;
    ans += t[i].first;
    if (--t[i].second == 0)
      ;
    else
      i--;
  }
  return ans;
}
int main() {
  read(n, m, K);
  for (i = 1; i <= n; i++) {
    scanf("%s", s + 1);
    for (j = 1; j <= m; j++) read(a[i].a[j], a[i].b[j], a[i].c[j]);
  }
  long long ans = 0;
  for (i = 1; i <= n; i++)
    for (j = 1; j <= n; j++)
      if (i != j) ans = max(ans, calc(a[i], a[j]));
  cout << ans << endl;
  return 0;
}
