#include <bits/stdc++.h>
using namespace std;
const int INF = 1 << 30;
typedef struct {
  int a, b, c;
} Item;
int main() {
  int n, m, cap;
  while (cin >> n >> m >> cap) {
    vector<vector<Item> > item(n, vector<Item>(m));
    for (int i = 0; i < n; ++i) {
      string s;
      cin >> s;
      for (int j = 0; j < m; ++j)
        cin >> item[i][j].a >> item[i][j].b >> item[i][j].c;
    }
    vector<vector<vector<pair<int, int> > > > diff(
        n, vector<vector<pair<int, int> > >(n, vector<pair<int, int> >(m)));
    for (int i = 0; i < n; ++i) {
      for (int j = 0; j < n; ++j) {
        if (i == j) continue;
        for (int k = 0; k < m; ++k) {
          diff[i][j][k].first = item[j][k].b - item[i][k].a;
          diff[i][j][k].second = item[i][k].c;
        }
      }
    }
    for (int i = 0; i < n; ++i) {
      for (int j = 0; j < n; ++j) {
        if (i == j) continue;
        sort(diff[i][j].rbegin(), diff[i][j].rend());
      }
    }
    int ans = 0;
    for (int i = 0; i < n; ++i) {
      for (int j = 0; j < n; ++j) {
        if (i == j) continue;
        int profit = 0, cnt = 0;
        for (int k = 0; k < m; ++k) {
          if (diff[i][j][k].first > 0) {
            int buy = min(cap - cnt, diff[i][j][k].second);
            profit += buy * diff[i][j][k].first;
            cnt += buy;
          }
        }
        ans = max(ans, profit);
      }
    }
    cout << ans << endl;
  }
  return 0;
}
