#include <bits/stdc++.h>
using namespace std;
int table[16][128][4];
int profit[128][16][16];
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 >> table[i][j][0] >> table[i][j][1] >> table[i][j][2];
    }
  }
  for (int i = 0; i < m; ++i) {
    for (int j = 0; j < n; ++j) {
      for (int l = 0; l < n; ++l) {
        profit[i][j][l] = table[l][i][1] - table[j][i][0];
      }
    }
  }
  int res = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      if (i != j) {
        int a[m];
        for (int ii = 0; ii < m; ++ii) a[ii] = ii;
        for (int ii = 0; ii < m; ++ii) {
          for (int jj = ii + 1; jj < m; ++jj) {
            if (profit[a[ii]][i][j] < profit[a[jj]][i][j]) {
              swap(a[ii], a[jj]);
            }
          }
        }
        int buy = k;
        int total = 0;
        for (int ii = 0; ii < m; ++ii) {
          if (profit[a[ii]][i][j] > 0) {
            int b = min(buy, table[i][a[ii]][2]);
            buy -= b;
            total += b * profit[a[ii]][i][j];
          }
        }
        res = max(res, total);
      }
    }
  }
  cout << res << endl;
  return 0;
}
