#include <bits/stdc++.h>
using namespace std;
struct prod {
  int compra, venta, total;
};
int com, ven, n, m, k, dp[110][110];
vector<prod> v[12];
int optimo(int ind, int ki) {
  if (ki <= 0 || ind >= m) return 0;
  if (dp[ind][ki] >= 0) return dp[ind][ki];
  int mej = 0;
  for (int j = 0; j <= min(ki, v[com][ind].total); j++) {
    mej = max(mej, j * (v[ven][ind].venta - v[com][ind].compra) +
                       optimo(ind + 1, ki - j));
  }
  return dp[ind][ki] = mej;
}
int main() {
  string second;
  cin >> n >> m >> k;
  prod p;
  for (int i = (int)0; i < (int)n; i++) {
    cin >> second;
    for (int j = (int)0; j < (int)m; j++) {
      cin >> p.compra >> p.venta >> p.total;
      v[i].push_back(p);
    }
  }
  int may = 0;
  for (int i = (int)0; i < (int)n; i++) {
    com = i;
    for (int j = (int)0; j < (int)n; j++) {
      ven = j;
      if (i != j) {
        memset(dp, -1, sizeof(dp));
        may = max(may, optimo(0, k));
      }
    }
  }
  cout << may << endl;
  return 0;
}
