#include <bits/stdc++.h>
using namespace std;
const int N = 11;
const int M = 101;
struct thing {
  int v, c;
  bool operator<(thing b) const { return v > b.v; }
};
int main() {
  int n, m, k;
  scanf("%d", &(n)), scanf("%d", &(m)), scanf("%d", &(k));
  int a[N][M], b[N][M], c[N][M];
  for (int i(0), _n(n); i < _n; ++i) {
    scanf("%*s");
    for (int j(0), _n(m); j < _n; ++j)
      scanf("%d", &(a[i][j])), scanf("%d", &(b[i][j])), scanf("%d", &(c[i][j]));
  }
  int ans = 0;
  for (int f(0), _n(n); f < _n; ++f)
    for (int t(0), _n(n); t < _n; ++t)
      if (f != t) {
        thing th[M];
        int l = 0;
        for (int j(0), _n(m); j < _n; ++j)
          if (b[t][j] > a[f][j]) {
            th[l].v = b[t][j] - a[f][j];
            th[l++].c = c[f][j];
          }
        sort(th, th + l);
        int tmp = 0, tk = k;
        for (int i(0), _n(l); i < _n; ++i) {
          int mn = min(tk, th[i].c);
          tmp += mn * th[i].v;
          tk -= mn;
          if (!tk) break;
        }
        if (tmp > ans) ans = tmp;
      }
  printf("%d\n", (ans));
  return 0;
}
