#include <bits/stdc++.h>
using namespace std;
const int N = 10000002, INF = 1000 * 1000 * 1000;
const long double eps = 1e-9;
struct node {
  int a, b, c, idx;
  node(int aa, int bb, int cc, int i) {
    a = aa;
    c = cc;
    b = bb;
    idx = i;
  }
  node(){};
};
vector<vector<node>> p;
int main() {
  int n, m, k;
  cin >> n >> m >> k;
  p.resize(n);
  for (int i = 0; i < n; ++i) {
    string s;
    cin >> s;
    p[i].resize(m);
    for (int j = 0; j < m; ++j) {
      int a, b, c;
      cin >> a >> b >> c;
      p[i][j] = node(a, b, c, i);
    }
  }
  int ans = 0;
  for (int f = 0; f < n; ++f) {
    for (int s = 0; s < n; ++s) {
      vector<pair<int, int>> a(m);
      int tmp = 0;
      for (int i = 0; i < m; ++i) {
        a[i] = make_pair(p[s][i].b - p[f][i].a, i);
      }
      sort(a.begin(), a.end());
      reverse(a.begin(), a.end());
      int cnt = k;
      for (int i = 0; i < m; ++i) {
        if (a[i].first < 0) break;
        int kol = min(p[f][a[i].second].c, cnt);
        tmp += kol * a[i].first;
        cnt -= kol;
      }
      ans = max(ans, tmp);
    }
  }
  cout << ans;
  return 0;
}
