#include <bits/stdc++.h>
using namespace std;
int n, types, k;
int arr[10][100][3];
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n;
  cin >> types;
  cin >> k;
  long long best = 0;
  for (int i = 0; i < n; i++) {
    string tm;
    cin >> tm;
    for (int j = 0; j < types; j++) {
      cin >> arr[i][j][0];
      cin >> arr[i][j][1];
      cin >> arr[i][j][2];
    }
  }
  for (int a = 0; a < n; a++) {
    for (int b = 0; b < n; b++) {
      if (a == b) continue;
      vector<int> chg;
      for (int i = 0; i < types; i++) {
        if (arr[a][i][0] < arr[b][i][1]) {
          for (int j = 0; j < arr[a][i][2]; j++)
            chg.push_back(arr[b][i][1] - arr[a][i][0]);
        }
      }
      long long sum = 0;
      sort(chg.begin(), chg.end());
      reverse(chg.begin(), chg.end());
      for (int i = 0; i < min((int)chg.size(), k); i++) sum += chg[i];
      best = max(best, sum);
    }
  }
  cout << best;
  return 0;
}
