#include <bits/stdc++.h>
using namespace std;
const int N = 10004;
const long long MOD = 1000000007;
const int OO = INT_MAX;
inline long long mod(long long x) { return x % MOD; }
long long n, m;
long long bounty, inc, dmg;
struct Char {
  long long id;
  long long maxi;
  long long cur;
  long long reg;
  long long lki;
  long long dead;
  long long last_health;
  Char(long long id, long long maxi, long long cur, long long reg)
      : id(id),
        maxi(maxi),
        cur(cur),
        reg(reg),
        lki(0),
        dead(0),
        last_health(cur){};
};
struct Event {
  long long t;
  long long info;
  long long cid;
  long long type;
  Event(long long t, long long info, long long cid, long long type)
      : t(t), info(info), cid(cid), type(type){};
  bool operator<(const Event& e) const {
    if (t == e.t) return type < e.type;
    return t < e.t;
  };
};
vector<Char> chars;
vector<Event> events;
long long cbounty;
long long ans;
long long dead;
void check_opt(long long t) {
  long long value = dead * (bounty + inc * t);
  if (cbounty < value) {
    cbounty = value;
    ans = t;
  }
}
int main() {
  std::ios::sync_with_stdio(false);
  cin >> n >> m;
  cin >> bounty >> inc >> dmg;
  bool inf = false;
  dead = 0;
  for (int i = 0; i < n; i++) {
    long long mh, sh, reg;
    cin >> mh >> sh >> reg;
    inf = inf || (inc > 0 && (mh <= dmg));
    chars.push_back(Char(i, mh, sh, reg));
    if (sh <= dmg) {
      dead++;
      chars[i].dead = 1;
      if (reg > 0) {
        long long t = (dmg - sh) / reg + 1;
        events.push_back(Event(t, 0, i, -1));
      }
    }
  }
  cbounty = dead * bounty;
  ans = 0;
  for (int i = 0; i < m; i++) {
    long long time, enemy, health;
    cin >> time >> enemy >> health;
    enemy--;
    chars[enemy].last_health = health;
    if (health <= dmg) {
      events.push_back(Event(time, time, enemy, 1));
      if (chars[enemy].reg > 0) {
        long long t = (dmg - health) / chars[enemy].reg + 1;
        events.push_back(Event(t + time, time, enemy, -1));
      }
    } else {
      events.push_back(Event(time, time, enemy, -1));
    }
  }
  for (int i = 0; i < n; i++)
    inf = inf || (inc > 0 && chars[i].last_health <= dmg && chars[i].reg == 0);
  if (inf) goto infinity;
  sort(events.begin(), events.end());
  for (auto e : events) {
    auto& c = chars[e.cid];
    if (e.type == 1) {
      if (!c.dead) {
        dead++;
        check_opt(e.t);
        c.dead = 1;
      }
      c.lki = e.t;
    } else {
      if (c.dead && e.info >= c.lki) {
        check_opt(e.t - 1);
        dead--;
        c.dead = 0;
        c.lki = e.t;
      }
    }
  }
  cout << cbounty << endl;
  return 0;
infinity:
  cout << -1 << endl;
}
