#include <bits/stdc++.h>
using namespace std;
struct Seg {
  long long add[100000 * 2 * 2 * 4 + 5];
  void update(long long ul, long long ur, long long l, long long r,
              long long idx) {
    if (l > ur || r < ul) return;
    if (l >= ul && r <= ur) {
      add[idx]++;
      return;
    }
    long long m = (l + r) / 2;
    update(ul, ur, l, m, idx * 2);
    update(ul, ur, m + 1, r, idx * 2 + 1);
  }
  long long query(long long x, long long l, long long r, long long idx) {
    if (l > x || r < x) return 0;
    if (l == x && r == x) return add[idx];
    long long m = (l + r) / 2;
    long long q1 = query(x, l, m, idx * 2);
    long long q2 = query(x, m + 1, r, idx * 2 + 1);
    return q1 + q2 + add[idx];
  }
} tree;
struct Event {
  long long t, chg, recov;
  bool ok;
  bool operator<(const Event &e) const { return t < e.t; }
};
struct Enemy {
  long long id, hp, mhp, reg;
  vector<Event> event;
};
long long N, M, boun, inc, dmg;
vector<long long> used;
map<long long, long long> trans;
Enemy en[100000 + 5];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> N >> M >> boun >> inc >> dmg;
  for (long long i = 0; i < N; i++) {
    auto &e = en[i];
    e.id = i;
    cin >> e.mhp >> e.hp >> e.reg;
    long long diff = dmg - e.hp;
    long long recov = e.reg == 0 ? (0x7FFFFFFFFFFFFFFF / 2) : diff / e.reg;
    if (diff < 0)
      e.event.push_back({0, e.hp, 0, false});
    else
      e.event.push_back({0, e.hp, recov, true});
    if (inc > 0 && (e.mhp <= dmg || (e.reg == 0 && e.hp <= dmg))) {
      cout << -1 << '\n';
      return 0;
    }
  }
  for (long long i = 0; i < M; i++) {
    long long t, id, nhp, recov, diff;
    cin >> t >> id >> nhp;
    id--;
    auto &e = en[id].event;
    diff = dmg - nhp;
    if (diff < 0) {
      e.push_back({t, nhp, t, false});
      continue;
    }
    recov = en[id].reg == 0 ? (0x7FFFFFFFFFFFFFFF / 2) : diff / en[id].reg;
    e.push_back({t, nhp, t + recov, true});
  }
  for (long long i = 0; i < N; i++) {
    sort(en[i].event.begin(), en[i].event.end());
    for (long long j = 0; j < en[i].event.size(); j++) {
      auto &e = en[i].event[j];
      if (j + 1 < en[i].event.size() && e.recov >= en[i].event[j + 1].t) {
        e.recov = en[i].event[j + 1].t - 1;
      }
      used.push_back(e.t);
      used.push_back(e.recov);
    }
  }
  used.push_back(0);
  used.push_back((0x7FFFFFFFFFFFFFFF / 2));
  sort(used.begin(), used.end());
  used.resize(unique(used.begin(), used.end()) - used.begin());
  for (long long i = 0; i < used.size(); i++) {
    trans[used[i]] = i + 1;
  }
  long long sz = used.size();
  for (long long i = 0; i < N; i++) {
    for (const auto &e : en[i].event) {
      if (!e.ok) continue;
      long long l = trans[e.t], r = trans[e.recov];
      tree.update(l, r, 1, sz, 1);
    }
  }
  long long ans = 0;
  for (long long i = 1; i <= sz; i++) {
    long long q = tree.query(i, 1, sz, 1);
    long long mul = used[i - 1];
    ans = max(ans, boun * q + q * mul * inc);
  }
  cout << ans << '\n';
}
