#include <bits/stdc++.h>
using namespace std;
int a[11][101];
int b[11][101];
int c[11][101];
int ta[11][101];
int tb[11][101];
int tc[11][101];
int main() {
  int n, m, k;
  cin >> n >> m >> k;
  string s;
  for (int i = 0; i < n; ++i) {
    cin >> s;
    for (int j = 0; j < m; ++j) {
      cin >> ta[i][j] >> tb[i][j] >> tc[i][j];
    }
  }
  int ans = 0;
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < n; ++j)
      if (i != j) {
        int res = 0;
        for (int ii = 0; ii < n; ++ii)
          for (int jj = 0; jj < m; ++jj) {
            a[ii][jj] = ta[ii][jj];
            b[ii][jj] = tb[ii][jj];
            c[ii][jj] = tc[ii][jj];
          }
        for (int ii = 0; ii < k; ++ii) {
          int maxn = -1;
          int type = -1;
          for (int t = 0; t < m; ++t)
            if (c[i][t] > 0 && b[j][t] - a[i][t] > maxn) {
              maxn = b[j][t] - a[i][t];
              type = t;
            }
          if (maxn != -1) {
            res += b[j][type] - a[i][type];
            --c[i][type];
          }
        }
        ans = max(ans, res);
      }
  cout << ans << endl;
  return 0;
}
