#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
constexpr ll IN = 1, OUT = 0, inf = LONG_LONG_MAX - 10000000000ll;
ll get_next_out(ll currh, ll damage, ll regh) {
  if (currh > damage) return 0;
  if (currh == damage && regh != 0) return 1;
  if (regh == 0) return inf;
  ll ret = (damage - currh) / regh + 1;
  return ret;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ll n, m;
  cin >> n >> m;
  ll bounty, increase, damage;
  cin >> bounty >> increase >> damage;
  vector<ll> start(n), max_health(n), regen(n);
  for (int i = 0; i < n; i += 1) cin >> max_health[i] >> start[i] >> regen[i];
  vector<vector<pair<ll, ll>>> health_update(n);
  for (int i = 0; i < m; i += 1) {
    ll time, enemy, health;
    cin >> time >> enemy >> health;
    enemy--;
    health_update[enemy].emplace_back(time, health);
  }
  map<ll, vector<pair<ll, ll>>> updates;
  for (int i = 0; i < n; i += 1) {
    ll currh = start[i], maxh = max_health[i], regh = regen[i];
    if (maxh <= damage) continue;
    ll next_out;
    if (currh <= damage)
      next_out = 1 + get_next_out(currh + regh, damage, regh);
    else
      next_out = 0;
    sort(begin(health_update[i]), end(health_update[i]),
         [](const pair<ll, ll> &lhs, const pair<ll, ll> &rhs) {
           return lhs.first < rhs.first;
         });
    for (const auto &p : health_update[i]) {
      ll update_time = p.first, update_value = p.second;
      if (update_time > next_out) {
        updates[next_out].emplace_back(i, OUT);
      }
      updates[update_time].emplace_back(i, (update_value <= damage ? IN : OUT));
      currh = update_value;
      next_out = update_time + 1 + get_next_out(currh + regh, damage, regh);
    }
    if (next_out < inf) updates[next_out].emplace_back(i, OUT);
  }
  vector<ll> status(n), last(n + 1, -1);
  last[0] = 0;
  ll count = 0ll;
  for (int i = 0; i < n; i += 1) {
    status[i] = (start[i] <= damage ? IN : OUT);
    if (status[i] == IN) count++;
  }
  last[count] = 0;
  for (const auto &p : updates) {
    ll when = p.first;
    last[count] = when - 1;
    for (const auto &p2 : p.second) {
      ll who = p2.first, what = p2.second;
      if (status[who] == what) continue;
      status[who] = what;
      if (what == IN)
        count++;
      else
        count--;
    }
  }
  if (count != 0ll && increase != 0)
    cout << -1 << endl;
  else {
    ll best = 0ll;
    for (int i = 1; i < n + 1; i += 1) {
      if (last[i] != -1) best = max(best, i * (bounty + last[i] * increase));
    }
    cout << best << endl;
  }
  return 0;
}
