#include <bits/stdc++.h>
using namespace std;
struct node {
  int a, b, left, value;
};
char name[1000];
int a[12][120][3];
node b[120];
int n, m, k;
bool cmp(node a, node b) { return a.value > b.value; }
int check(int u, int v) {
  for (int i = 1; i <= m; ++i) {
    b[i].left = a[u][i][2];
    b[i].value = a[v][i][1] - a[u][i][0];
  }
  sort(b + 1, b + m + 1, cmp);
  int ret = 0, now = 1;
  for (int i = 1; i <= k; ++i) {
    if (now == m + 1) break;
    if (b[now].value < 0) break;
    if (b[now].left == 0) {
      --i;
      ++now;
      continue;
    }
    ret += b[now].value;
    b[now].left--;
  }
  return ret;
}
int main() {
  while (scanf("%d%d%d", &n, &m, &k) == 3) {
    int ans = 0;
    for (int i = 1; i <= n; ++i) {
      scanf("%s", name);
      for (int j = 1; j <= m; ++j)
        scanf("%d%d%d", &a[i][j][0], &a[i][j][1], &a[i][j][2]);
    }
    for (int i = 1; i <= n; ++i)
      for (int j = 1; j <= n; ++j) {
        if (i == j) continue;
        ans = max(ans, check(i, j));
      }
    cout << ans << endl;
  }
  return 0;
}
