#include <bits/stdc++.h>
using namespace std;
int n, m, k, ans;
int priceBuy[15][105];
int priceSell[15][105];
int itemCount[15][105];
pair<int, int> itemProfit[105];
int main() {
  cin >> n >> m >> k;
  for (int i = 1; i <= n; i++) {
    string garbage;
    cin >> garbage;
    for (int j = 1; j <= m; j++) {
      cin >> priceBuy[i][j] >> priceSell[i][j] >> itemCount[i][j];
    }
  }
  for (int planetBuy = 1; planetBuy <= n; planetBuy++) {
    for (int planetSell = 1; planetSell <= n; planetSell++) {
      for (int item = 1; item <= m; item++) {
        itemProfit[item] = {
            priceSell[planetSell][item] - priceBuy[planetBuy][item],
            itemCount[planetBuy][item]};
      }
      sort(itemProfit + 1, itemProfit + m + 1, greater<pair<int, int>>());
      int itemCnt = 0, item = 1, profit = 0;
      while (itemCnt < k && item <= m && itemProfit[item].first > 0) {
        profit +=
            itemProfit[item].first * min(k - itemCnt, itemProfit[item].second);
        itemCnt += min(k - itemCnt, itemProfit[item].second);
        item++;
      }
      ans = max(ans, profit);
    }
  }
  cout << ans;
}
