#include <bits/stdc++.h>
using namespace std;
int A[20][200], B[20][200], C[20][200];
vector<pair<int, int> > P;
int main() {
  char buf[300];
  int i, j, m, n, k, p, t;
  scanf("%d%d%d", &n, &m, &k);
  for (i = 0; i < n; i++) {
    scanf("%s", buf);
    for (j = 0; j < m; j++) scanf("%d%d%d", &A[i][j], &B[i][j], &C[i][j]);
  }
  int ans = 0, ans1;
  for (i = 0; i < n; i++)
    for (j = 0; j < n; j++)
      if (j != i) {
        ans1 = 0;
        P.clear();
        for (p = 0; p < m; p++)
          P.push_back(make_pair(B[j][p] - A[i][p], C[i][p]));
        sort(P.begin(), P.end());
        t = k;
        for (p = P.size() - 1; p >= 0; p--)
          if ((P[p].first > 0) && (t > 0)) {
            ans1 += min(t, P[p].second) * P[p].first;
            t -= min(t, P[p].second);
          }
        ans = max(ans, ans1);
      }
  printf("%d\n", ans);
  return 0;
}
