#include <bits/stdc++.h>
using namespace std;
typedef struct goods {
  int buy;
  int sell;
  int num;
} goods;
typedef struct goods_profit {
  int profit;
  int num;
  bool operator<(const goods_profit &gp) const { return profit > gp.profit; }
} goods_profit;
int n, m, k;
goods gds[15][105];
void count_profit(int p1, int p2, goods_profit gp[]) {
  for (int i = 0; i < m; i++) {
    gp[i].profit = gds[p2][i].sell - gds[p1][i].buy;
    gp[i].num = gds[p1][i].num;
  }
  sort(gp, gp + m);
}
int trade(int p1, int p2) {
  int ans = 0;
  int residue = k;
  goods_profit gp[105];
  count_profit(p1, p2, gp);
  int sum_profit = 0;
  int index = 0;
  while (residue > 0 && index < m) {
    if (gp[index].profit <= 0) break;
    if (residue >= gp[index].num) {
      sum_profit += gp[index].num * gp[index].profit;
      residue -= gp[index].num;
      index++;
    } else {
      sum_profit += residue * gp[index].profit;
      residue = 0;
      index++;
    }
  }
  return sum_profit;
}
int main() {
  while (cin >> n >> m >> k) {
    for (int i = 0; i < n; i++) {
      string name;
      cin >> name;
      for (int j = 0; j < m; j++)
        cin >> gds[i][j].buy >> gds[i][j].sell >> gds[i][j].num;
    }
    int sum = 0;
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        sum = max(sum, trade(i, j));
      }
    }
    cout << sum << endl;
  }
  return 0;
}
