#include <bits/stdc++.h>
using namespace std;
struct item {
  int buy, sell, count;
  bool operator<(const item& it) const {
    return (sell - buy) > (it.sell - it.buy);
  }
};
int num[10][100][3];
int n, m, K;
char name[10][12];
item items[100];
int main() {
  while (scanf("%d%d%d", &n, &m, &K) != EOF) {
    int maxprofit = 0;
    for (int i = 0; i < n; ++i) {
      scanf("%s", name[i]);
      for (int j = 0; j < m; ++j) {
        scanf("%d%d%d", &num[i][j][0], &num[i][j][1], &num[i][j][2]);
      }
    }
    for (int i = 0; i < n; ++i) {
      for (int j = 0; j < n; ++j) {
        if (j == i) continue;
        for (int k = 0; k < m; ++k) {
          items[k].buy = num[i][k][0];
          items[k].sell = num[j][k][1];
          items[k].count = num[i][k][2];
        }
        sort(items, items + m);
        int profit = 0;
        int count = K;
        for (int k = 0; k < m && items[k].sell > items[k].buy; ++k) {
          if (count > items[k].count) {
            profit += items[k].count * (items[k].sell - items[k].buy);
            count -= items[k].count;
          } else {
            profit += count * (items[k].sell - items[k].buy);
            count = 0;
          }
        }
        if (maxprofit < profit) maxprofit = profit;
      }
    }
    printf("%d\n", maxprofit);
  }
}
