#include <bits/stdc++.h>
using namespace std;
int N, M, K, num[12][200], buy[12][200], sell[12][200];
int ans;
int main() {
  cin >> N >> M >> K;
  for (int i = 0; i < N; i++) {
    char s[1000];
    scanf("%s", s);
    for (int j = 0; j < M; j++) {
      int a, b, c;
      scanf("%d%d%d", &a, &b, &c);
      sell[i][j] = b;
      buy[i][j] = a;
      num[i][j] = c;
    }
  }
  for (int i = 0; i < N; i++)
    for (int j = 0; j < N; j++)
      if (i != j) {
        vector<int> tmp;
        int r = 0;
        for (int k = 0; k < M; k++)
          for (int l = 0; l < num[j][k]; l++)
            tmp.push_back(sell[i][k] - buy[j][k]);
        sort(tmp.begin(), tmp.end(), greater<int>());
        for (int k = 0; k < K && k < tmp.size(); k++)
          if (tmp[k] > 0) r += tmp[k];
        ans = max(ans, r);
      }
  cout << ans << endl;
  return 0;
}
