#include <bits/stdc++.h>
using namespace std;
struct Item {
  int a, b, c;
};
Item item(int a, int b, int c) {
  Item x;
  x.a = a;
  x.b = b;
  x.c = c;
  return x;
}
int main() {
  vector<Item> v[100];
  int n, m, k;
  cin >> n >> m >> k;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    int a, b, c;
    for (int j = 0; j < m; j++) {
      cin >> a >> b >> c;
      v[i].push_back(item(a, b, c));
    }
  }
  int ans = 0;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++)
      if (i != j) {
        pair<int, int> s[100];
        for (int u = 0; u < m; u++) {
          s[u].first = v[i][u].b - v[j][u].a;
          s[u].second = v[j][u].c;
        }
        sort(s, s + m);
        reverse(s, s + m);
        int kk = k, cur = 0;
        for (int u = 0; u < m; u++) {
          if (s[u].first < 0 || kk == 0) break;
          if (kk < s[u].second) {
            cur = cur + kk * s[u].first;
            break;
          } else {
            cur = cur + s[u].second * s[u].first;
            kk -= s[u].second;
          }
        }
        ans = max(ans, cur);
      }
  cout << ans << endl;
  return 0;
}
