#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:260108864")
using namespace std;
struct prod {
  int b, s, a;
};
vector<vector<prod> > d;
vector<pair<int, int> > cur;
int main() {
  int n, m, k;
  scanf("%d%d%d\n", &n, &m, &k);
  d.resize(n);
  for (int i(0); i <= ((int)(n)-1); ++i) {
    char buf[100];
    gets(buf);
    d[i].resize(m);
    for (int j(0); j <= ((int)(m)-1); ++j)
      scanf("%d%d%d\n", &d[i][j].b, &d[i][j].s, &d[i][j].a);
  }
  int res(0);
  for (int i(0); i <= ((int)(n)-1); ++i) {
    for (int j(0); j <= ((int)(n)-1); ++j) {
      if (i == j) continue;
      cur.clear();
      cur.reserve(m);
      for (int q(0); q <= ((int)(m)-1); ++q)
        if (d[i][q].b < d[j][q].s)
          cur.push_back(make_pair(-d[i][q].b + d[j][q].s, d[i][q].a));
      sort((cur).begin(), (cur).end());
      reverse((cur).begin(), (cur).end());
      int can(k);
      int now(0);
      int ans(0);
      while (now != ((int)cur.size()) && can > 0) {
        if (now < ((int)cur.size())) {
          if (cur[now].second > can)
            ans += cur[now].first * can, can = 0;
          else
            ans += cur[now].first * cur[now].second, can -= cur[now].second;
          ++now;
        }
      }
      res = max(res, ans);
    }
  }
  printf("%d\n", res);
  return 0;
}
