#include <bits/stdc++.h>
int n, m, K, Name[20], a[20][110], b[20][110], c[20][110], Pro[110], Max[110],
    p[110], Now, Ans, ANS;
bool cmp(int a, int b) { return Pro[a] > Pro[b]; }
int Min(int a, int b) { return a < b ? a : b; }
int main() {
  int i, j, k, l;
  scanf("%d%d%d", &n, &m, &K);
  for (i = 0; i < n; i++) {
    scanf("%s", Name + i);
    for (j = 0; j < m; j++) scanf("%d%d%d", a[i] + j, b[i] + j, c[i] + j);
  }
  for (i = 0; i < n; i++)
    for (j = 0; j < n; j++) {
      for (k = 0; k < m; k++) {
        Pro[k] = b[i][k] - a[j][k];
        Max[k] = c[j][k];
      }
      for (k = 0; k < m; k++) p[k] = k;
      std::sort(p, p + m, cmp);
      Now = K;
      Ans = 0;
      for (k = 0; k < m && Pro[p[k]] > 0 && Now > 0; k++) {
        l = Min(Now, Max[p[k]]);
        Ans += l * Pro[p[k]];
        Now -= l;
      }
      if (Ans > ANS) ANS = Ans;
    }
  printf("%d\n", ANS);
  return 0;
}
