#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1.0);
const double eps = 1e-11;
const int inf = 0x7FFFFFFF;
template <class T>
inline void checkmin(T &a, T b) {
  if (b < a) a = b;
}
template <class T>
inline void checkmax(T &a, T b) {
  if (b > a) a = b;
}
template <class T>
inline T sqr(T x) {
  return x * x;
}
template <class T>
void show(T a, int n) {
  for (int i = 0; i < n; ++i) cout << a[i] << ' ';
  cout << endl;
}
template <class T>
void show(T a, int r, int l) {
  for (int i = 0; i < r; ++i) show(a[i], l);
  cout << endl;
}
int a[11][101], b[11][101], c[11][101];
int main() {
  int n, m, k;
  while (cin >> n >> m >> k) {
    string tmp;
    for (int i = 0; i < n; i++) {
      cin >> tmp;
      for (int j = 0; j < m; j++) cin >> a[i][j] >> b[i][j] >> c[i][j];
    }
    int ans = 0;
    for (int i = 0; i < n; i++)
      for (int j = 0; j < n; j++)
        if (i != j) {
          vector<int> vec;
          for (int kk = 0; kk < m; kk++)
            for (int t = 0; t < c[i][kk]; t++)
              vec.push_back(b[j][kk] - a[i][kk]);
          sort(vec.begin(), vec.end());
          int tans = 0;
          for (int tt = 1; tt <= k; tt++)
            if (tt <= vec.size() && vec[vec.size() - tt] > 0)
              tans += vec[vec.size() - tt];
          checkmax(ans, tans);
        }
    cout << ans << endl;
  }
  return 0;
}
