#include <bits/stdc++.h>
using namespace std;
int n, m, k;
int a[15][123];
int b[15][123];
int c[15][123];
vector<int> v;
bool cmp(int x, int y) { return x > y; }
int main() {
  cin >> n >> m >> k;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    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) continue;
      v.clear();
      for (int h = 0; h < m; h++)
        for (int t = 0; t < c[i][h]; t++)
          if (b[j][h] - a[i][h] > 0) v.push_back(b[j][h] - a[i][h]);
      sort(v.begin(), v.end(), cmp);
      int tmp = 0;
      for (int h = 0; h < min(k, (int)v.size()); h++) tmp += v[h];
      ans = max(ans, tmp);
    }
  cout << ans << endl;
  return 0;
}
