#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline T sqr(const T &a) {
  return a * a;
}
template <typename T>
inline int nread(vector<T> &a) {
  int n;
  cin >> n;
  a.clear();
  a.resize(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  return n;
}
int main() {
  int n, m, k;
  cin >> n >> m >> k;
  vector<vector<int> > b, s, c;
  b.assign(n, vector<int>(m, 0));
  s = c = b;
  for (int i = 0; i < n; i++) {
    string ss;
    cin >> ss;
    for (int j = 0; j < m; j++) cin >> b[i][j] >> s[i][j] >> c[i][j];
  }
  vector<vector<int> > tc = c;
  int res = 0;
  for (int st = 0; st < n; st++) {
    for (int en = 0; en < n; en++) {
      c = tc;
      int cres = 0;
      for (int i = 0; i < k; i++) {
        int bst = -1, win = 0;
        for (int j = 0; j < m; j++)
          if (c[st][j] > 0 && s[en][j] - b[st][j] > win) {
            win = s[en][j] - b[st][j];
            bst = j;
          }
        if (bst == -1) break;
        c[st][bst]--;
        cres += win;
      }
      res = max(res, cres);
    }
  }
  cout << res << endl;
}
