#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m, cap, i, j, k, ans, a, b, c, x, r;
  cin >> n >> m >> cap;
  string s;
  vector<vector<int>> buy(n, vector<int>(m));
  vector<vector<int>> sell(n, vector<int>(m));
  vector<vector<int>> total(n, vector<int>(m));
  for (i = 0; i < n; i++) {
    cin >> s;
    for (j = 0; j < m; j++) cin >> buy[i][j] >> sell[i][j] >> total[i][j];
  }
  ans = 0;
  for (j = 0; j < n; j++) {
    for (k = 0; k < n; k++) {
      vector<int> v;
      for (i = 0; i < m; i++) {
        for (r = 0; r < total[k][i]; r++) {
          if (sell[j][i] > buy[k][i]) v.push_back(sell[j][i] - buy[k][i]);
        }
      }
      sort(v.rbegin(), v.rend());
      x = 0;
      for (i = 0; (i < cap) && (i < v.size()); i++) x += v[i];
      ans = max(ans, x);
    }
  }
  cout << ans << "\n";
  return 0;
}
