#include <bits/stdc++.h>
using namespace std;
int goods[20][1010][3];
char str[1010];
pair<int, int> pa[1010];
int main() {
  int n, m, k, ans = 0;
  scanf("%d%d%d", &n, &m, &k);
  for (int i = 0; i < n; ++i) {
    scanf("%s", str);
    for (int j = 0; j < m; ++j)
      for (int l = 0; l < 3; ++l) scanf("%d", &goods[i][j][l]);
  }
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < n; ++j) {
      for (int l = 0; l < m; ++l)
        pa[l] = make_pair(goods[j][l][1] - goods[i][l][0], goods[i][l][2]);
      sort(pa, pa + m);
      int tk = k, tmp = 0;
      for (int l = m - 1; l >= 0 && tk && pa[l].first > 0; --l) {
        tmp += pa[l].first * min(tk, pa[l].second);
        tk -= min(tk, pa[l].second);
      }
      ans = max(ans, tmp);
    }
  printf("%d\n", ans);
  return 0;
}
