#include <bits/stdc++.h>
using namespace std;
string s;
int a[11][105][3];
int f[10000];
struct point {
  int v, b;
} g[10000];
int main() {
  int n, m, kkk;
  cin >> n >> m >> kkk;
  for (int i = 0; i < n; i++) {
    cin >> s;
    for (int j = 0; j < m; j++)
      scanf("%d%d%d", &a[i][j][0], &a[i][j][1], &a[i][j][2]);
  }
  int ans = 0;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) {
      memset(f, 0, sizeof(f));
      int l = 0;
      for (int k = 0; k < m; k++) {
        int t = a[i][k][2];
        int tt = 1;
        while (t - tt >= 0) {
          g[l].v = tt * (a[j][k][1] - a[i][k][0]);
          g[l].b = tt;
          l++;
          t -= tt;
          tt *= 2;
        }
        if (t) g[l].v = t * (a[j][k][1] - a[i][k][0]), g[l].b = t, l++;
      }
      for (int ii = 0; ii < l; ii++)
        for (int jj = kkk; jj >= g[ii].b; jj--)
          if (f[jj] < f[jj - g[ii].b] + g[ii].v)
            f[jj] = f[jj - g[ii].b] + g[ii].v;
      if (f[kkk] > ans) ans = f[kkk];
    }
  cout << ans;
}
