#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:16777216")
using namespace std;
const double pi = 3.141592653589793238462;
const int nmax = 150;
const int hash_base = 119;
const long long inf = 2e18;
int n, m, k, cost[nmax][nmax][3], Answer = 0, p[nmax], A, B;
string name;
void Try() {
  bool used[nmax];
  memset(used, false, sizeof(used));
  int ans = 0, lt = k;
  for (int i = 1; i <= m && lt; i++) {
    int best_num = -1, best_val = -1;
    for (int j = 1; j <= m; j++)
      if (!used[j] &&
          (best_num == -1 || best_val < cost[B][j][1] - cost[A][j][0]) &&
          cost[B][j][1] - cost[A][j][0] > 0) {
        best_num = j;
        best_val = cost[B][j][1] - cost[A][j][0];
      };
    if (best_num != -1) {
      used[best_num] = true;
      int v = cost[A][best_num][2];
      while (lt && v) {
        --lt;
        --v;
        ans += best_val;
      };
    };
  };
  Answer = max(Answer, ans);
};
int main() {
  cin >> n >> m >> k;
  for (int i = 1; i <= n; i++) {
    cin >> name;
    for (int j = 1; j <= m; j++)
      for (int k = 0; k < 3; k++) cin >> cost[i][j][k];
  };
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++)
      if (i != j) {
        A = i;
        B = j;
        Try();
      };
  cout << Answer << endl;
  return 0;
}
