#include <bits/stdc++.h>
using namespace std;
int n, m, k, a[12][128], b[12][128], c[12][128], d[12][128], ans = 0;
int main() {
  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];
  }
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < n; ++j) {
      int sum = 0;
      for (int l = 0; l < m; ++l) d[i][l] = c[i][l];
      for (int l = 0; l < k; ++l) {
        int best = -1;
        for (int p = 0; p < m; ++p)
          if (d[i][p] &&
              b[j][p] - a[i][p] > (best == -1 ? 0 : b[j][best] - a[i][best]))
            best = p;
        if (best != -1) {
          --d[i][best];
          sum += b[j][best] - a[i][best];
        }
      }
      ans = max(ans, sum);
    }
  cout << ans;
  return 0;
}
