#include <bits/stdc++.h>
using namespace std;
const int NMAX = 105;
int a[NMAX][NMAX], b[NMAX][NMAX], c[NMAX][NMAX];
int best(int i, int j, int n, int m) {
  pair<int, int> d[m];
  for (int k = 0; k < m; ++k) {
    d[k] = {b[j][k] - a[i][k], c[i][k]};
  }
  sort(d, d + m, greater<pair<int, int> >());
  int g = 0, k = 0;
  while (n > 0) {
    if (d[k].first > 0) {
      if (d[k].second > n) {
        g += n * d[k].first;
        n = 0;
      } else {
        g += d[k].second * d[k].first;
        n -= d[k].second;
      }
    } else {
      break;
    }
    ++k;
    if (k == m) {
      break;
    }
  }
  return g;
}
int main() {
  int n, m, k;
  cin >> n >> m >> k;
  for (int i = 0; i < n; ++i) {
    string name;
    cin >> name;
    for (int j = 0; j < m; ++j) {
      cin >> a[i][j] >> b[i][j] >> c[i][j];
    }
  }
  int sol = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      if (i != j) {
        sol = max(sol, best(i, j, k, m));
      }
    }
  }
  cout << sol << endl;
  return 0;
}
