#include <bits/stdc++.h>
using namespace std;
const int dr[] = {1, 0, -1, 0, 1, 1, -1, -1};
const int dc[] = {0, 1, 0, -1, 1, -1, -1, 1};
const double eps = 1e-9;
const int INF = 0x7FFFFFFF;
const long long INFLL = 0x7FFFFFFFFFFFFFFFLL;
const double pi = acos(-1);
struct point_i {
  int x, y;
  point_i(int _x = 0, int _y = 0) {
    x = _x;
    y = _y;
  }
};
struct point {
  double x, y;
  point(double _x = 0, double _y = 0) {
    x = _x;
    y = _y;
  }
  bool operator<(const point &other) const {
    if (fabs(x - other.x) < eps) return y < other.y;
    return x < other.x;
  }
};
struct line_s {
  point beg, end;
  line_s() {
    beg = point(0, 0);
    end = point(0, 0);
  }
  line_s(point a, point b) : beg(a), end(b) {}
  bool intersect(const line_s &other, point &ans) {
    double mua, mub;
    double denom, numera, numerb;
    denom = (other.end.y - other.beg.y) * (end.x - beg.x) -
            (other.end.x - other.beg.x) * (end.y - beg.y);
    numera = (other.end.x - other.beg.x) * (beg.y - other.beg.y) -
             (other.end.y - other.beg.y) * (beg.x - other.beg.x);
    numerb = (end.x - beg.x) * (beg.y - other.beg.y) -
             (end.y - beg.y) * (beg.x - other.beg.x);
    if (denom == 0 && numera == 0 && numerb == 0) return 0;
    mua = numera / denom;
    mub = numerb / denom;
    if (mua < 0 || mua > 1 || mub < 0 || mub > 1) {
      ans.x = 0;
      ans.y = 0;
      return 0;
    }
    ans.x = beg.x + mua * (end.x - beg.x);
    ans.y = beg.y + mua * (end.y - beg.y);
    return 1;
  }
};
struct line {
  double a, b, c, len;
  line() { a = b = c = 0.0; }
  line(const point &a_, const point &b_) {
    if (fabs(a_.x - b_.x) < eps) {
      a = 1.0;
      b = 0.0;
      c = -a_.x;
    } else {
      a = -(double)(a_.y - b_.y) / (a_.x - b_.x);
      b = 1.0;
      c = -(double)(a_.x * a) - (double)(a_.y * b);
    }
    if (fabs(a) < eps) a = fabs(a);
    if (fabs(b) < eps) b = fabs(b);
    if (fabs(c) < eps) c = fabs(c);
    double x = a_.x - b_.x, y = a_.y - b_.y;
    len = sqrt((x * x) + (y * y));
  }
  bool parallel(const line &other) {
    return (fabs(a - other.a) < eps && fabs(b - other.b) < eps);
  }
  bool same(const line &other) {
    return (*this).parallel(other) && fabs(c - other.c) < eps;
  }
};
long long n, m, k, a, b, c;
long long ans;
string st;
vector<vector<pair<pair<long long, long long>, long long> > > vc;
int main() {
  ans = 0LL;
  cin >> n >> m >> k;
  vector<pair<pair<long long, long long>, long long> > z;
  z.clear();
  vc.assign(n + 1, z);
  for (int(iz) = (0), _t = (n); iz < (_t); ++(iz)) {
    cin >> st;
    for (int(i) = (0), _t = (m); i < (_t); ++(i)) {
      cin >> a >> b >> c;
      vc[iz].push_back(make_pair(make_pair(a, b), c));
    }
  }
  for (int(iz) = (0), _t = (n); iz < (_t); ++(iz)) {
    for (int(jz) = (0), _t = (n); jz < (_t); ++(jz))
      if (iz == jz)
        continue;
      else {
        vector<pair<long long, long long> > tmp;
        tmp.clear();
        for (int(i) = (0), _t = (m); i < (_t); ++(i))
          tmp.push_back(
              make_pair(vc[jz][i].first.second - vc[iz][i].first.first,
                        vc[iz][i].second));
        sort(tmp.begin(), tmp.end(), greater<pair<long long, long long> >());
        long long anz = 0, tmpk = k;
        for (int(i) = (0), _t = ((int)tmp.size()); i < (_t); ++(i)) {
          if (tmp[i].first < 0) break;
          if (tmp[i].second < tmpk) {
            tmpk -= tmp[i].second;
            anz += tmp[i].second * tmp[i].first;
          } else {
            anz += tmpk * tmp[i].first;
            break;
          }
        }
        if (anz > ans) ans = anz;
      }
  }
  cout << ans << endl;
  return 0;
}
