#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
string planet[11];
int a[11][111], b[11][111], c[11][111];
int dp[111][111];
int main() {
  int n, m, sum;
  scanf("%d%d%d", &n, &m, &sum);
  for (int j = 0; j < n; j++) {
    cin >> planet[j];
    for (int k = 0; k < m; k++) scanf("%d%d%d", &a[j][k], &b[j][k], &c[j][k]);
  }
  int ans = -1;
  for (int gg = 0; gg < n; gg++) {
    for (int hh = 0; hh < n; hh++) {
      if (gg == hh) continue;
      memset(dp, 135, sizeof(dp));
      for (int j = 0; j <= sum; j++) dp[0][j] = 0;
      for (int j = 1; j <= m; j++) {
        dp[j][0] = 0;
        for (int k = 1; k <= sum; k++) {
          for (int l = 0; l <= k && l <= c[gg][j - 1]; l++) {
            dp[j][k] = max(
                dp[j][k], dp[j - 1][k - l] + l * (b[hh][j - 1] - a[gg][j - 1]));
          }
        }
      }
      int ha = -1;
      for (int j = 0; j <= sum; j++) ha = max(ha, dp[m][j]);
      ans = max(ans, ha);
    }
  }
  printf("%d\n", ans);
  return 0;
}
