#include <bits/stdc++.h>
using namespace std;
const int maxn = 105;
int n, m, k;
struct node {
  int m[maxn][3];
} a[15];
int dp[maxn];
int DP(int s, int t) {
  memset(dp, 0, sizeof(dp));
  for (int j = 1; j <= m; ++j)
    for (int i = k; i >= 0; --i)
      for (int l = min(k, a[s].m[j][2]); l >= 0; --l) {
        if (i + l > k) continue;
        dp[i + l] = max(dp[i + l], dp[i] + l * (a[t].m[j][1] - a[s].m[j][0]));
      }
  int ret = 0;
  for (int i = 0; i <= k; ++i) ret = max(ret, dp[i]);
  return ret;
}
int main() {
  string str;
  while (cin >> n >> m >> k) {
    for (int i = 1; i <= n; ++i) {
      cin >> str;
      for (int j = 1; j <= m; ++j)
        cin >> a[i].m[j][0] >> a[i].m[j][1] >> a[i].m[j][2];
    }
    int ans = 0;
    for (int i = 1; i <= n; ++i)
      for (int j = 1; j <= n; ++j) {
        if (i == j) continue;
        ans = max(ans, DP(i, j));
      }
    cout << ans << endl;
  }
}
