#include <bits/stdc++.h>
using namespace std;
const long double eps = 1e-9;
const int inf = (1 << 30) - 1;
const long long inf64 = ((long long)1 << 62) - 1;
const long double pi = 3.1415926535897932384626433832795;
const string task = "";
template <class T>
T sqr(T x) {
  return x * x;
}
const int nmax = 1000;
int a[nmax][nmax], b[nmax][nmax], c[nmax][nmax];
int main() {
  int n, m, k;
  cin >> n >> m >> k;
  for (int i = 0; i < (int)(n); i++) {
    string s;
    cin >> s;
    for (int j = 0; j < (int)(m); j++) cin >> a[i][j] >> b[i][j] >> c[i][j];
  }
  int res = 0;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++)
      if (i != j) {
        vector<int> now;
        for (int k = 0; k < (int)(m); k++)
          for (int l = 0; l < (int)(c[i][k]); l++)
            now.push_back(b[j][k] - a[i][k]);
        sort(now.begin(), now.end());
        reverse(now.begin(), now.end());
        int cnt = 0;
        for (int w = 0; w < (int)(now.size()); w++) {
          if (w >= k) break;
          cnt += now[w];
          res = max(res, cnt);
        }
      }
  cout << res << endl;
  return 0;
}
