#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
long long n, m;
long long bounty, increase, damage;
long long maxHealth[100005], curHealth[100005], regen[100005];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long seed;
  asm("rdtsc" : "=A"(seed));
  srand(seed);
  cin >> n >> m;
  cin >> bounty >> increase >> damage;
  vector<pair<long long, bool>> e[100005];
  long long maxmax = 0;
  long long noregen = 0;
  for (long long i = 1; i <= n; i++) {
    long long mh, ch, r;
    cin >> mh >> ch >> r;
    maxHealth[i] = mh;
    maxmax = max(maxmax, mh);
    curHealth[i] = ch;
    regen[i] = r;
    if (!r) noregen = 1;
    if (ch <= damage) {
      e[i].push_back({0, 0});
      if (r) e[i].push_back({(1 + (damage - ch) / r), 1});
    }
  }
  if (increase && (maxmax <= damage || noregen)) {
    cout << -1 << endl;
    return 0;
  }
  vector<pair<long long, pair<long long, long long>>> temp;
  for (long long i = 0; i < m; i++) {
    long long t, idx, h;
    cin >> t >> idx >> h;
    temp.push_back({t, {idx, h}});
  }
  sort(temp.begin(), temp.end());
  for (auto p : temp) {
    long long t = p.first, i = p.second.first, h = p.second.second;
    if (maxHealth[i] <= damage) continue;
    if (regen[i] == 0) {
      if (h <= damage) {
        if (e[i].empty() || e[i].back().second == 1) {
          e[i].push_back({t, 0});
        }
      } else {
        if (!e[i].empty() && e[i].back().second == 0) e[i].push_back({t, 1});
      }
      continue;
    }
    if (h > damage) {
      if (e[i].empty()) continue;
      if (e[i].back().first > t) {
        e[i].pop_back();
        e[i].push_back({t, 1});
      }
    } else {
      if (e[i].empty()) {
        e[i].push_back({t, 0});
        e[i].push_back({t + 1 + (damage - h) / regen[i], 1});
      } else {
        if (e[i].back().first <= t) {
          e[i].push_back({t, 0});
          e[i].push_back({t + 1 + (damage - h) / regen[i], 1});
        } else {
          e[i].pop_back();
          e[i].push_back({t + 1 + (damage - h) / regen[i], 1});
        }
      }
    }
  }
  vector<pair<long long, long long>> f;
  for (long long i = 1; i <= n; i++) {
    for (auto p : e[i]) {
      f.push_back(p);
    }
  }
  sort(f.begin(), f.end());
  long long cur = 0;
  long long ans = 0;
  for (long long i = 0; i < f.size(); i++) {
    if (i != 0 && f[i].first != f[i - 1].first)
      ans = max(ans, cur * (bounty + ((f[i].first - 1) * increase)));
    if (f[i].second == 1) cur--;
    if (f[i].second == 0) cur++;
    if (i != f.size() - 1 && f[i].first == f[i + 1].first) continue;
    ans = max(ans, cur * (bounty + ((f[i].first - 1) * increase)));
  }
  cout << ans << endl;
}
