#include <bits/stdc++.h>
const int maxi = 2000000000;
const int maxq = 1000000000;
const double eps = 1e-10;
const double pi = 3.1415926535897932;
const double inf = 1e+18;
const int mo = 1000000007;
using namespace std;
pair<int, int> f[111111];
char tmp[11111];
int a[1111][1111], b[1111][1111], c[1111][1111], n, m, k, siz;
int main() {
  scanf("%d%d%d\n", &n, &m, &siz);
  for (int i = 0; i < n; i++) {
    gets(tmp);
    for (int j = 0; j < m; j++) {
      scanf("%d", &a[i][j]);
      scanf("%d", &b[i][j]);
      scanf("%d", &c[i][j]);
    }
    scanf("\n");
  }
  int ans = 0;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++)
      if (i != j) {
        for (int k = 0; k < m; k++)
          f[k].first = b[j][k] - a[i][k], f[k].second = k;
        sort(f, f + m);
        reverse(f, f + m);
        int may = siz;
        int sum = 0;
        for (int k = 0; k < m; k++)
          if (f[k].first > 0 && may) {
            int kol = min(may, c[i][f[k].second]);
            sum = sum + f[k].first * kol;
            may -= kol;
          }
        ans = max(ans, sum);
      }
  cout << ans << endl;
  return 0;
}
