#include <bits/stdc++.h>
using namespace std;
struct node {
  int profit, num;
  node() {}
  node(int a, int b) {
    profit = a;
    num = b;
  }
};
bool cmp(const node &a, const node &b) {
  if (a.profit != b.profit)
    return a.profit > b.profit;
  else
    return a.num > b.num;
}
struct node1 {
  int x, y, z;
  node1() {}
  node1(int a, int b, int c) {
    x = a;
    y = b;
    z = c;
  }
};
vector<node1> data[15];
int main() {
  int n, m, k;
  scanf("%d%d%d", &n, &m, &k);
  for (int i = 0; i < n; i++) {
    string str;
    cin >> str;
    for (int j = 0; j < m; j++) {
      int a, b, c;
      scanf("%d%d%d", &a, &b, &c);
      data[i].push_back(node1(a, b, c));
    }
  }
  long long imax = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (i == j) continue;
      vector<node> item;
      for (int x = 0; x < m; x++) {
        item.push_back(node(-data[i][x].x + data[j][x].y, data[i][x].z));
      }
      sort(item.begin(), item.end(), cmp);
      int total = k, ind = 0;
      long long sum = 0;
      while (total > 0 && ind < (int)item.size()) {
        if (item[ind].profit <= 0) break;
        if (total > item[ind].num) {
          sum += item[ind].profit * item[ind].num;
          total -= item[ind++].num;
        } else {
          sum += total * item[ind].profit;
          total = 0;
          break;
        }
      }
      imax = max(imax, sum);
    }
  }
  cout << imax << endl;
  return 0;
}
