#include <bits/stdc++.h>
using namespace std;
int a[20][200];
int b[20][200];
int c[20][200];
int vis[200];
int n, m, k;
int solve(int x, int y) {
  memset(vis, 0, sizeof(vis));
  int last = k;
  int ans = 0;
  while (last) {
    int flag = 0;
    int Max = 0;
    int Maxc = 0;
    for (int i = 1; i <= m; i++) {
      if (vis[i]) continue;
      if (b[y][i] - a[x][i] > Max) {
        Max = b[y][i] - a[x][i];
        Maxc = i;
        flag = 1;
      }
    }
    if (!flag) break;
    int num = min(last, c[x][Maxc]);
    ans += num * Max;
    vis[Maxc] = 1;
    last -= num;
  }
  return ans;
}
int main() {
  scanf("%d%d%d", &n, &m, &k);
  for (int i = 1; i <= n; i++) {
    string s;
    cin >> s;
    for (int j = 1; j <= m; j++) scanf("%d%d%d", &a[i][j], &b[i][j], &c[i][j]);
  }
  int ans = 0;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++) ans = max(ans, solve(i, j));
  printf("%d\n", ans);
}
