#include <bits/stdc++.h>
using namespace std;
int dp[12][12][102][102];
pair<pair<int, int>, int> v[12][102];
int m;
int rec(int buy, int sel, int articulo, int resto) {
  if (dp[buy][sel][articulo][resto] <= -1000000000) {
    if (resto == 0 || articulo == m) return dp[buy][sel][articulo][resto] = 0;
    int i, maximo = 0, minimo = min(resto, v[buy][articulo].second);
    for (i = 0; i <= minimo; i++)
      maximo = max(maximo, rec(buy, sel, articulo + 1, resto - i) -
                               (v[buy][articulo].first.first * i) +
                               (v[sel][articulo].first.second * i));
    return dp[buy][sel][articulo][resto] = maximo;
  }
  return dp[buy][sel][articulo][resto];
}
int main() {
  int a, b, i, j, k, n, maximo = 0;
  char s[12][12];
  scanf("%d%d%d", &n, &m, &k);
  for (i = 0; i < n; i++) {
    scanf("%s", s[i]);
    for (j = 0; j < m; j++) {
      scanf("%d%d%d", &v[i][j].first.first, &v[i][j].first.second,
            &v[i][j].second);
    }
  }
  for (i = 0; i < n; i++)
    for (j = 0; j < n; j++)
      for (a = 0; a <= m; a++)
        for (b = 0; b <= k; b++) dp[i][j][a][b] = -1000000000;
  for (i = 0; i < n; i++)
    for (j = 0; j < n; j++)
      if (i != j) maximo = max(maximo, rec(i, j, 0, k));
  cout << maximo << endl;
  return 0;
}
