#include <bits/stdc++.h>
using namespace std;
const int MAXN = 11, MAXM = 110;
int a[MAXN][MAXM], b[MAXN][MAXM], c[MAXN][MAXM];
int main(void) {
  int n, m, K;
  scanf("%d%d%d", &n, &m, &K);
  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 res = 0;
  for (int i = 0; i < (n); ++i) {
    for (int j = 0; j < (n); ++j) {
      if (i == j) {
        continue;
      }
      vector<pair<int, int> > s;
      for (int k = 0; k < (m); ++k) {
        s.push_back(make_pair(b[j][k] - a[i][k], c[i][k]));
      }
      sort((s).begin(), (s).end(), greater<pair<int, int> >());
      int rem = K, can = 0;
      for (__typeof((s).begin()) it = (s).begin(); it != (s).end(); ++it) {
        if (it->first <= 0) {
          break;
        }
        int g = min(rem, it->second);
        can += g * it->first;
        rem -= g;
      }
      res = max(res, can);
    }
  }
  printf("%d\n", res);
  return 0;
}
