#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 15;
const long long int inf = 1e18;
vector<vector<long long int> > a(20, vector<long long int>(110));
vector<vector<long long int> > b(20, vector<long long int>(110));
vector<vector<long long int> > c(20, vector<long long int>(110));
long long int n, m, k;
long long int get(long long int ind1, long long int ind2) {
  vector<long long int> profit;
  for (long long int i = 0; i < m; i++) {
    for (long long int j = 0; j < c[ind1][i]; j++)
      profit.push_back(b[ind2][i] - a[ind1][i]);
  }
  sort(profit.rbegin(), profit.rend());
  long long int ans = 0;
  for (long long int i = 0; i < min(k, (long long int)profit.size()); i++) {
    if (profit[i] <= 0)
      break;
    else
      ans += profit[i];
  }
  return ans;
}
void solve() {
  cin >> n >> m >> k;
  for (long long int i = 0; i < n; i++) {
    string s;
    cin >> s;
    for (long long int j = 0; j < m; j++) cin >> a[i][j] >> b[i][j] >> c[i][j];
  }
  long long int ans = 0;
  for (long long int i = 0; i < n; i++) {
    for (long long int j = 0; j < n; j++) {
      if (i != j) ans = max(ans, get(i, j));
    }
  }
  cout << ans;
}
void debug(long long int tt) {}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int t = 1;
  while (t--) {
    solve();
  }
}
