#include <bits/stdc++.h>
using namespace std;
const int inf = 2147483647;
const long long llinf = 9223372036854775807LL;
int a[11][101];
int b[11][101];
int c[11][101];
int diff[111];
int ct[111];
int dp[111] = {0};
int main() {
  int n, m, k;
  cin >> n >> m >> k;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    for (int j = 0; j < m; j++) cin >> a[i][j] >> b[i][j] >> c[i][j];
  }
  int res = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (i != j) {
        for (int l = 0; l < m; l++) {
          diff[l] = b[j][l] - a[i][l];
          ct[l] = c[i][l];
        }
        for (int l = 1; l <= k; l++) {
          int mx = 0;
          int ind = 0;
          for (int f = 0; f < m; f++)
            if (ct[f] > 0 && mx < diff[f]) {
              mx = diff[f];
              ind = f;
            }
          dp[l] = dp[l - 1] + mx;
          ct[ind]--;
        }
        for (int l = 0; l <= k; l++)
          if (dp[l] > res) res = dp[l];
      }
    }
  }
  cout << res;
  return 0;
}
