#include <bits/stdc++.h>
int i, j, k, C, v, N, M, K, Ans;
char Name[1005];
int a[105][105], b[105][105], c[105][105], f[1005];
int main() {
  scanf("%d%d%d", &N, &M, &K);
  for (i = 1; i <= N; ++i) {
    scanf("%s", Name);
    for (j = 1; j <= M; ++j) scanf("%d%d%d", &a[i][j], &b[i][j], &c[i][j]);
  }
  for (i = 1; i <= N; ++i)
    for (j = 1; j <= N; ++j)
      if (i != j) {
        memset(f, 0, sizeof(f));
        for (k = 1; k <= M; ++k)
          if (a[i][k] < b[j][k])
            for (C = 1; C <= c[i][k]; ++C)
              for (v = K; v; --v)
                if (f[v - 1] + b[j][k] - a[i][k] > f[v])
                  f[v] = f[v - 1] + b[j][k] - a[i][k];
        if (f[K] > Ans) Ans = f[K];
      }
  printf("%d\n", Ans);
  return 0;
}
