#include <bits/stdc++.h>
using namespace std;
int l, m, n, cap, infos[11][4][1111], ans = INT_MIN;
char planet[22];
pair<int, int> profit[1111];
bool mySort(pair<int, int> a, pair<int, int> b) {
  if (a.first == b.first) return a.second > b.second;
  return a.first > b.first;
}
int findProfit(int p) {
  int ret = INT_MIN;
  int temp, ava;
  for (int i = (0); i < (l); ++i) {
    for (int j = (0); j < (m); ++j) {
      if (i != p) {
        profit[j] =
            (pair<int, int>((infos[i][1][j] - infos[p][0][j]), infos[p][2][j]));
      }
    }
    sort(profit, profit + m, mySort);
    temp = 0;
    ava = n;
    for (int j = (0); j < (m); ++j) {
      if ((!ava) || profit[j].first < 1) break;
      temp += (profit[j].first * min(profit[j].second, ava));
      ava -= min(profit[j].second, ava);
    }
    ret = max(ret, temp);
  }
  return ret;
}
int main() {
  scanf("%d %d %d", &l, &m, &n);
  for (int i = (0); i < (l); ++i) {
    scanf("%s", planet);
    for (int j = (0); j < (m); ++j) {
      scanf("%d %d %d", &infos[i][0][j], &infos[i][1][j], &infos[i][2][j]);
    }
  }
  for (int i = (0); i < (l); ++i) {
    ans = max(ans, findProfit(i));
  }
  printf("%d\n", ans);
  return 0;
}
