#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:256000000")
using namespace std;
using ll = long long;
using ull = unsigned long long;
struct HealthEvent {
  ll time;
  ll health;
  HealthEvent() {}
  HealthEvent(ll _time, ll _health) : time(_time), health(_health) {}
};
struct VulnerableEvent {
  ll time;
  bool vulnerable;
  VulnerableEvent(ll _time, bool _vulnerable)
      : time(_time), vulnerable(_vulnerable) {}
};
void solve() {
  int n, m;
  scanf("%d%d", &n, &m);
  ll bounty, increase, damage;
  scanf("%lld%lld%lld", &bounty, &increase, &damage);
  vector<ll> max_health(n), start_health(n), regen(n);
  for (int i = 0; i < n; ++i)
    scanf("%lld%lld%lld", &max_health[i], &start_health[i], &regen[i]);
  vector<vector<HealthEvent>> health_events(n, vector<HealthEvent>());
  for (int i = 0; i < m; ++i) {
    HealthEvent e;
    int enemy;
    scanf("%lld%d%lld", &e.time, &enemy, &e.health);
    health_events[enemy - 1].push_back(e);
  }
  vector<VulnerableEvent> vulnerable_events;
  for (int i = 0; i < n; ++i) {
    vector<HealthEvent>& events = health_events[i];
    events.push_back(HealthEvent(0LL, start_health[i]));
    sort(events.begin(), events.end(),
         [](HealthEvent& a, HealthEvent& b) { return a.time < b.time; });
    bool vulnerable = false;
    for (int j = 0; j < events.size(); ++j) {
      ll time = events[j].time;
      ll health = events[j].health;
      if (health <= damage) {
        if (!vulnerable) {
          vulnerable_events.push_back(VulnerableEvent(time, true));
          vulnerable = true;
        }
        if (max_health[i] > damage && regen[i] != 0LL) {
          ll nvtime = time + (damage - health) / regen[i] + 1;
          if (j + 1 == events.size() || events[j + 1].time > nvtime) {
            vulnerable_events.push_back(VulnerableEvent(nvtime, false));
            vulnerable = false;
          }
        }
      } else {
        if (vulnerable) {
          vulnerable_events.push_back(VulnerableEvent(time, false));
          vulnerable = false;
        }
      }
    }
  }
  int cnt_vulnerable = 0;
  sort(vulnerable_events.begin(), vulnerable_events.end(),
       [](VulnerableEvent a, VulnerableEvent b) {
         return a.time < b.time ||
                a.time == b.time && a.vulnerable < b.vulnerable;
       });
  ll answer = 0;
  for (int i = 0; i < vulnerable_events.size(); ++i) {
    VulnerableEvent e = vulnerable_events[i];
    if (e.vulnerable == false) {
      answer = max(answer, cnt_vulnerable * (bounty + (e.time - 1) * increase));
      --cnt_vulnerable;
    } else {
      ++cnt_vulnerable;
      answer = max(answer, cnt_vulnerable * (bounty + e.time * increase));
    }
  }
  if (increase != 0 && cnt_vulnerable > 0) answer = -1;
  printf("%lld", answer);
}
int main() {
  solve();
  return 0;
}
