#include <bits/stdc++.h>
using namespace std;
long long damage;
struct event {
  long long time;
  long long healthUpdate;
  long long enemy;
  long long setTime;
  bool forced;
  bool operator<(event o) const {
    if (time != o.time) return time < o.time;
    if (forced != o.forced) return forced;
    bool killableA = healthUpdate <= damage;
    bool killableB = o.healthUpdate <= damage;
    if (killableA != killableB) return killableA;
    if (setTime != o.setTime) return setTime > o.setTime;
    return enemy < o.enemy;
  }
};
long long timeTillKillable(long long currHealth, long long regen,
                           long long threshold) {
  return (threshold - currHealth) / regen;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long n, m;
  cin >> n >> m;
  long long bounty, increase;
  cin >> bounty >> increase >> damage;
  vector<long long> maxHealth(n);
  vector<long long> regen(n);
  vector<event> events;
  set<long long> checkTimes;
  checkTimes.insert(0);
  for (long long i = 0; i < n; i++) {
    long long s;
    cin >> maxHealth[i] >> s >> regen[i];
    events.push_back({0, s, i, 0, true});
    if (s <= damage) {
      if (maxHealth[i] > damage and regen[i] > 0) {
        long long ttk = timeTillKillable(s, regen[i], damage);
        events.push_back({ttk + 1, (ttk + 1) * regen[i] + s, i, 0, false});
        checkTimes.insert(ttk);
      }
    }
  }
  for (long long i = 0; i < m; i++) {
    long long time, enemy, health;
    cin >> time >> enemy >> health;
    --enemy;
    events.push_back({time, health, enemy, time, true});
    if (health <= damage and maxHealth[enemy] > damage and regen[enemy] > 0) {
      long long ttk = timeTillKillable(health, regen[enemy], damage);
      events.push_back({time + ttk + 1, (ttk + 1) * regen[enemy] + health,
                        enemy, time, false});
      checkTimes.insert(time + ttk);
    } else {
      checkTimes.insert(time - 1);
    }
  }
  sort(events.begin(), events.end());
  long long lastTime = events[events.size() - 1].time + 1;
  checkTimes.insert(lastTime);
  set<long long> killable;
  vector<long long> latestEvent(n, -1);
  long long currEvent = 0;
  long long best = 0;
  for (long long currTime : checkTimes) {
    while (currEvent < events.size() and events[currEvent].time <= currTime) {
      event curr = events[currEvent++];
      if (curr.forced) {
        latestEvent[curr.enemy] = curr.time;
      } else if (curr.setTime < latestEvent[curr.enemy]) {
        continue;
      }
      if (curr.healthUpdate <= damage) {
        killable.insert(curr.enemy);
      } else {
        killable.erase(curr.enemy);
      }
    }
    best =
        max(best, (long long)killable.size() * (bounty + currTime * increase));
  }
  if (killable.size() > 0 and increase > 0) {
    cout << -1 << '\n';
  } else {
    cout << best << '\n';
  }
  return 0;
}
