#include <bits/stdc++.h>
using namespace std;
class planet {
 public:
  string name;
  vector<int> a, b, c;
  static int n, m, k;
  planet() {
    a.resize(m);
    b.resize(m);
    c.resize(m);
  }
  void operator()() {
    cin >> name;
    for (int j = 0; j < planet::m; j++) {
      cin >> a[j] >> b[j] >> c[j];
    }
  }
  friend vector<int> operator-(const vector<int>& v1, vector<int>& v2) {
    size_t maxsize, minsize;
    if (v1.size() < v2.size()) {
      maxsize = v2.size();
      minsize = v1.size();
    } else {
      maxsize = v1.size();
      minsize = v2.size();
    }
    vector<int> v3(maxsize, 0);
    unsigned int i = 0;
    for (; i < minsize; i++) {
      v3[i] += v1[i] - v2[i];
    }
    for (; i < v1.size(); i++) {
      v3[i] += v1[i];
    }
    for (; i < v2.size(); i++) {
      v3[i] -= v2[i];
    }
    return v3;
  }
  static void simplex1P(vector<vector<float> >& tab, vector<int>& itab,
                        int it) {
    int var = itab[it];
    if (tab[2 * m + 1][var + 1] >= 0 &&
        ((tab[2 * m + 1][var + 1] / tab[var][var + 1]) <
         (tab[2 * m + 1][m + 1] / tab[var][m + 1]))) {
      float pv1 = tab[var][0];
      float pv2 = tab[var][m + 1];
      for (int i = 0; i < 2 * m + 2; i++) {
        tab[i][var + 1] /= tab[var][var + 1];
        tab[i][0] -= pv1 * tab[i][var + 1];
        tab[i][m + 1] -= pv2 * tab[i][var + 1];
      }
    } else if (tab[2 * m + 1][m + 1] >= 0) {
      float pv1 = tab[var][0];
      float pv2 = tab[var][var + 1];
      for (int i = 0; i < 2 * m + 2; i++) {
        tab[i][m + 1] /= tab[var][m + 1];
        tab[i][0] -= pv1 * tab[i][m + 1];
        tab[i][var + 1] -= pv2 * tab[i][m + 1];
      }
    } else {
      return;
    }
  }
  friend float operator*(const planet& buy, const planet& sell) {
    vector<vector<float> > tab(2 * m + 2, vector<float>(m + 2, 0));
    for (int j = 0; j < m; j++) {
      tab[j][0] = buy.a[j] - sell.b[j];
      tab[j][m + 1] = 1;
    }
    for (int j = 0; j < m; j++) {
      tab[j][j + 1] = 1;
      tab[j + m][j + 1] = 1;
      tab[2 * m + 1][j + 1] = buy.c[j];
    }
    tab[2 * m][m + 1] = 1;
    tab[2 * m + 1][m + 1] = k;
    vector<int> itab(m);
    for (int i = 0; i < m; ++i) {
      itab[i] = i;
    }
    sort(itab.begin(), itab.end(), [&tab](const int a, const int b) -> bool {
      return (tab[a][0] < tab[b][0]);
    });
    for (int i = 0; i < m; i++) {
      if (tab[itab[i]][0] >= 0) {
        break;
      }
      planet::simplex1P(tab, itab, i);
    }
    return tab[2 * m + 1][0];
  }
};
int planet::n = 0;
int planet::m = 0;
int planet::k = 0;
int main() {
  int n, m, k;
  cin >> n >> m >> k;
  planet::n = n;
  planet::m = m;
  planet::k = k;
  vector<planet> planets(n);
  for (int p = 0; p < n; p++) {
    planets[p]();
  }
  float maxprofit = 0;
  for (int ibuy = 0; ibuy < n; ibuy++) {
    for (int isell = ibuy + 1; isell < n; isell++) {
      int cost = planets[ibuy] * planets[isell];
      if (cost > maxprofit) {
        maxprofit = cost;
      }
      cost = planets[isell] * planets[ibuy];
      if (cost > maxprofit) {
        maxprofit = cost;
      }
    }
  }
  cout << maxprofit << endl;
  return 0;
}
