#include <bits/stdc++.h>
const double eps = 1e-7, PI = 3.1415926;
const int N = 1e6;
using namespace std;
int n, m, k, a[400][400], sum, b[300][300], c[300][300];
string s;
vector<pair<int, int> > vec;
int main() {
  scanf("%d", &n);
  scanf("%d", &m);
  scanf("%d", &k);
  for (int i = 0; i < n; i++) {
    cin >> s;
    for (int j = 0; j < m; j++) {
      scanf("%d", &a[i][j]);
      scanf("%d", &b[i][j]);
      scanf("%d", &c[i][j]);
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (i == j) continue;
      int x = k;
      for (int l = 0; l < m; l++) {
        vec.push_back(make_pair(b[j][l] - a[i][l], c[i][l]));
      }
      sort(vec.begin(), vec.end());
      reverse(vec.begin(), vec.end());
      int y = 0;
      for (int l = 0; l < m; l++) {
        if (x <= 0 || vec[l].first <= 0) break;
        int z = min(vec[l].second, x);
        y += z * vec[l].first;
        x -= z;
      }
      sum = max(sum, y);
      vec.clear();
    }
  }
  cout << sum;
  return 0;
}
