#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:20000000")
using namespace std;
int ri() {
  int x;
  scanf("%d", &x);
  return x;
}
long long rll() {
  long long x;
  scanf("%lld", &x);
  return x;
}
int n, m, k;
int dp[105];
int c[15][105];
int a[15][105];
int b[15][105];
int check(int pos1, int pos2) {
  memset(dp, -1, sizeof(dp));
  dp[0] = 0;
  for (int i = (int)(1); i <= (int)(m); i++) {
    int q = c[pos1][i];
    if (!q) continue;
    int diff = a[pos1][i] - b[pos2][i];
    diff *= -1;
    if (diff <= 0) continue;
    for (int j = (int)(k); j >= (int)(1); j--) {
      if (dp[j - 1] != -1 && dp[j] < dp[j - 1] + diff) {
        dp[j] = dp[j - 1] + diff;
        for (int t = (int)(j + 1); t <= (int)(min(k, j + q - 1)); t++)
          if (dp[t] < dp[t - 1] + diff)
            dp[t] = dp[t - 1] + diff;
          else
            break;
      }
    }
  }
  int res = 0;
  for (int i = (int)(1); i <= (int)(k); i++) res = max(res, dp[i]);
  return res;
}
void solve() {
  n = ri(), m = ri(), k = ri();
  int res = 0;
  for (int i = (int)(1); i <= (int)(n); i++) {
    string s;
    cin >> s;
    for (int j = (int)(1); j <= (int)(m); j++)
      a[i][j] = ri(), b[i][j] = ri(), c[i][j] = ri();
  }
  for (int i = (int)(1); i <= (int)(n); i++)
    for (int j = (int)(1); j <= (int)(n); j++)
      if (i != j) {
        res = max(res, check(i, j));
      }
  cout << res << endl;
}
int main() {
  solve();
  return 0;
}
