#include <bits/stdc++.h>
using namespace std;
int n, m, k;
int x, y, z;
int dp[101];
char name[11];
int maxgain = 0;
int tekgain = 0;
struct diff {
  int id;
  int amt;
};
diff D[101];
bool comp_less(diff a, diff b) {
  if (a.amt != b.amt) return (a.amt > b.amt);
  return (a.id > b.id);
}
struct item {
  int buy;
  int sell;
  int amt;
};
item It[11][101];
int main() {
  scanf("%d%d%d", &n, &m, &k);
  for (int i = 0; i < n; i++) {
    scanf("%s", &name);
    for (int j = 0; j < m; j++) {
      scanf("%d%d%d", &x, &y, &z);
      It[i][j].buy = x;
      It[i][j].sell = y;
      It[i][j].amt = z;
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (i != j) {
        tekgain = 0;
        for (int K = 0; K < m; K++) {
          D[K].id = K;
          D[K].amt = It[j][K].sell - It[i][K].buy;
        }
        sort(D, D + m, comp_less);
        int loaded = 0;
        for (int it = 0; it < m && loaded < k; it++) {
          if (D[it].amt <= 0)
            break;
          else {
            int it1 = D[it].id;
            if (It[i][it1].amt <= k - loaded) {
              tekgain += D[it].amt * It[i][it1].amt;
              loaded += It[i][it1].amt;
            } else {
              int delta = k - loaded;
              tekgain += D[it].amt * delta;
              loaded += delta;
            }
          }
        }
        if (tekgain > maxgain) maxgain = tekgain;
      }
    }
  }
  printf("%d\n", maxgain);
  return 0;
}
