#include <bits/stdc++.h>
using namespace std;
const int MAXN = 128;
int n, m, k, i, j, ans, buyPlanet, sellPlanet, willChange;
int a[MAXN][MAXN], b[MAXN][MAXN], c[MAXN][MAXN];
int F[MAXN], NF[MAXN];
string uselessInformation;
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n >> m >> k;
  for (i = 1; i <= n; i++) {
    cin >> uselessInformation;
    for (j = 1; j <= m; j++) cin >> a[i][j] >> b[i][j] >> c[i][j];
  }
  ans = 0;
  for (buyPlanet = 1; buyPlanet <= n; buyPlanet++) {
    for (sellPlanet = 1; sellPlanet <= n; sellPlanet++) {
      if (buyPlanet == sellPlanet) continue;
      for (j = 0; j <= k; j++) F[j] = -1;
      F[0] = 0;
      for (i = 1; i <= m; i++) {
        for (j = 0; j <= k; j++) NF[j] = -1;
        for (willChange = 0; willChange <= c[buyPlanet][i]; willChange++) {
          for (j = 0; j + willChange <= k; j++) {
            NF[j + willChange] =
                max(NF[j + willChange],
                    F[j] + (b[sellPlanet][i] - a[buyPlanet][i]) * willChange);
          }
        }
        for (j = 0; j <= k; j++) NF[j] = max(NF[j], F[j]);
        for (j = 0; j <= k; j++) F[j] = NF[j];
      }
      for (j = 0; j <= k; j++) ans = max(ans, F[j]);
    }
  }
  printf("%d\n", ans);
  return 0;
}
