#include <bits/stdc++.h>
using namespace std;
int n, m, k, a[10][100], b[10][100], c[10][100], v[10010], nv;
char name[10][100];
int main() {
  scanf("%d%d%d", &n, &m, &k);
  for (int i = 0; i < n; i++) {
    scanf("%s", name[i]);
    for (int j = 0; j < m; j++) scanf("%d%d%d", a[i] + j, b[i] + j, c[i] + j);
  }
  int ans = 0;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++)
      if (i != j) {
        nv = 0;
        for (int ii = 0; ii < m; ii++)
          for (int jj = 0; jj < c[i][ii]; jj++) v[nv++] = b[j][ii] - a[i][ii];
        sort(v, v + nv);
        int now = 0;
        for (int x = nv - 1; x >= nv - k && x >= 0 && v[x] > 0; x--)
          now += v[x];
        ans = max(ans, now);
      }
  printf("%d\n", ans);
  return 0;
}
