#include <bits/stdc++.h>
using namespace std;
int i, j, k, L, m, n, ans;
string s;
int a[11][101], b[11][101], c[11][101];
struct Item {
  int a, x;
} P;
bool operator<(Item a, Item b) { return a.a > b.a; };
vector<Item> V;
void check(int x, int y) {
  int i, sum, xsum, q;
  V.clear();
  for (i = 1; i <= m; i++) {
    P.x = c[x][i];
    P.a = b[y][i] - a[x][i];
    V.push_back(P);
  }
  sort(V.begin(), V.end());
  sum = xsum = 0;
  for (i = 0; i < m && xsum < L; i++) {
    q = min(L - xsum, V[i].x);
    if (V[i].a > 0) {
      xsum += q;
      sum += q * V[i].a;
    } else
      break;
  }
  ans = max(ans, sum);
}
int main() {
  cin >> n >> m >> L;
  for (i = 1; i <= n; i++) {
    cin >> s;
    for (j = 1; j <= m; j++) cin >> a[i][j] >> b[i][j] >> c[i][j];
  }
  for (i = 1; i <= n; i++)
    for (j = 1; j <= n; j++)
      if (i != j) check(i, j);
  cout << ans << endl;
}
