#include <bits/stdc++.h>
using namespace std;
int f[110];
int a[11][110], b[11][110], c[11][110];
int n, m, k;
int calc_ans(int x, int y) {
  int s = 0;
  memset(f, -1, sizeof(f));
  f[0] = 0;
  for (int t = 1; t <= m; t++)
    for (int j = 1; j <= c[x][t]; j++)
      for (int i = k; i >= 1; i--)
        if (f[i - 1] >= 0) {
          f[i] = max(f[i], f[i - 1] + b[y][t] - a[x][t]);
          s = max(s, f[i]);
        }
  return s;
}
void init() {
  cin >> n >> m >> k;
  for (int i = 1; i <= n; i++) {
    string str;
    cin >> str;
    for (int j = 1; j <= m; j++) cin >> a[i][j] >> b[i][j] >> c[i][j];
  }
}
void solve() {
  int ans = 0;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++)
      if (i != j) ans = max(ans, calc_ans(i, j));
  cout << ans << endl;
}
int main() {
  ios::sync_with_stdio(false);
  init();
  solve();
  return 0;
}
