#include <bits/stdc++.h>
using namespace std;
struct item {
  int a, b, c;
} q[11][111];
int n, m, k;
bool cmp(pair<int, int> a, pair<int, int> b) { return a.first > b.first; }
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m >> k;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    for (int j = 0; j < m; j++) {
      cin >> q[i][j].a >> q[i][j].b >> q[i][j].c;
    }
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (i == j) continue;
      vector<pair<int, int> > cherry;
      cherry.clear();
      for (int itr = 0; itr < m; itr++) {
        if (q[i][itr].c != 0 && q[j][itr].b - q[i][itr].a > 0)
          cherry.push_back({q[j][itr].b - q[i][itr].a, q[i][itr].c});
      }
      sort(cherry.begin(), cherry.end(), cmp);
      int itr = 0;
      int kk = k;
      int cur = 0;
      while (itr < cherry.size() && kk > 0) {
        int per, num;
        per = cherry[itr].first;
        num = cherry[itr].second;
        itr++;
        if (num >= kk) {
          cur += per * kk;
          break;
        } else {
          cur += per * num;
          kk -= num;
        }
      }
      ans = max(ans, cur);
    }
  }
  cout << ans << endl;
  return 0;
}
