#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 5;
long long N, M;
long long bounty, inc, dmg;
long long max_health[MAXN];
long long start_health[MAXN];
long long regen[MAXN];
struct eve {
  long long T, H;
  bool operator<(const eve &e) const { return T < e.T; }
};
vector<eve> events[MAXN];
vector<pair<long long, long long>> good_ranges;
int main() {
  cin.tie(0);
  cin.sync_with_stdio(0);
  cin >> N >> M;
  cin >> bounty >> inc >> dmg;
  for (int a = 1; a <= N; a++) {
    cin >> max_health[a];
    cin >> start_health[a];
    cin >> regen[a];
    if (max_health[a] <= dmg && inc != 0) {
      cout << -1;
      return 0;
    }
  }
  for (int a = 1; a <= M; a++) {
    int targ;
    eve e;
    cin >> e.T;
    cin >> targ;
    cin >> e.H;
    events[targ].push_back(e);
  }
  for (int a = 1; a <= N; a++) {
    sort(events[a].begin(), events[a].end());
    long long tm = 0, hl = start_health[a];
    for (eve e : events[a]) {
      if (hl <= dmg) {
        long long start_better =
            (regen[a] == 0 ? e.T : tm + 1 + (dmg - hl) / regen[a]);
        good_ranges.push_back({tm, min(e.T, start_better)});
      }
      hl = e.H;
      tm = e.T;
    }
    if (hl <= dmg) {
      if (regen[a] == 0 && inc != 0) {
        cout << -1;
        return 0;
      }
      long long start_better =
          regen[a] == 0 ? 1000000000000ll : tm + 1 + (dmg - hl) / regen[a];
      good_ranges.push_back({tm, start_better});
    }
  }
  priority_queue<long long, vector<long long>, greater<long long>> pq;
  sort(good_ranges.begin(), good_ranges.end());
  long long ans = 0;
  for (pair<long long, long long> p : good_ranges) {
    while (!pq.empty() && pq.top() <= p.first) {
      ans = max(ans, (long long)pq.size() *
                         (long long)(bounty + inc * (pq.top() - 1)));
      pq.pop();
    }
    pq.push(p.second);
  }
  while (!pq.empty()) {
    ans = max(
        ans, (long long)pq.size() * (long long)(bounty + inc * (pq.top() - 1)));
    pq.pop();
  }
  cout << ans;
}
