#include <bits/stdc++.h>
using namespace std;
const int N = 20;
const int M = 110;
struct good {
  int a, b, c;
};
int n, m, k;
string st[N];
good g[N][M];
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n >> m >> k;
  for (int i = 0; i < n; ++i) {
    cin >> st[i];
    for (int j = 0; j < m; ++j) {
      cin >> g[i][j].a >> g[i][j].b >> g[i][j].c;
    }
  }
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      if (i == j) continue;
      vector<pair<int, int> > v(m);
      for (int q = 0; q < m; ++q) {
        v[q] = make_pair(g[j][q].b - g[i][q].a, g[i][q].c);
      }
      sort(v.rbegin(), v.rend());
      int cur = 0, kol = 0;
      for (int q = 0; q < m; ++q) {
        if (kol == k || v[q].first <= 0) break;
        int t = min(v[q].second, k - kol);
        cur += v[q].first * t;
        kol += t;
      }
      ans = max(ans, cur);
    }
  }
  cout << ans << endl;
  return 0;
}
