#include <bits/stdc++.h>
using namespace std;
long long nextTime(long long time, long long health, long long maxHealth,
                   long long regen, long long damage) {
  if (maxHealth <= damage) {
    return 1e18;
  }
  if (health > damage) {
    return -1;
  }
  if (regen == 0) {
    return 1e18;
  }
  return (damage - health) / regen + time;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int test = 1;
  for (int T = 1; T <= test; ++T) {
    int N, M;
    cin >> N >> M;
    long long bounty, increase, damage;
    cin >> bounty >> increase >> damage;
    vector<long long> maxHealth(N + 1), startHealth(N + 1), regen(N + 1);
    for (int i = 1; i <= N; ++i) {
      cin >> maxHealth[i] >> startHealth[i] >> regen[i];
    }
    vector<pair<int, pair<long long, long long>>> updates;
    for (int i = 1; i <= N; ++i) {
      updates.push_back({0, {i, startHealth[i]}});
    }
    long long time, enemy, health;
    for (int i = 0; i < M; ++i) {
      cin >> time >> enemy >> health;
      updates.push_back({time, {enemy, health}});
    }
    sort(updates.begin(), updates.end());
    map<long long, long long> m;
    vector<long long> lastUpdate(N + 1, 1.1e18);
    for (int i = updates.size() - 1; i >= 0; --i) {
      time = updates[i].first, enemy = updates[i].second.first,
      health = updates[i].second.second;
      long long nt =
          nextTime(time, health, maxHealth[enemy], regen[enemy], damage);
      if (nt == -1) {
        lastUpdate[enemy] = time;
        continue;
      }
      if (nt >= lastUpdate[enemy]) {
        ++m[lastUpdate[enemy] - 1];
        --m[time - 1];
      } else {
        ++m[nt];
        --m[time - 1];
      }
      lastUpdate[enemy] = time;
    }
    if (m[1e18] > 0 && increase != 0) {
      cout << -1 << '\n';
      continue;
    }
    vector<pair<long long, long long>> v;
    for (auto p : m) {
      v.push_back(p);
    }
    int count = 0;
    long long maximum = 0;
    for (int i = v.size() - 1; i >= 0; --i) {
      count += v[i].second;
      maximum = max(maximum, count * (bounty + increase * v[i].first));
    }
    cout << maximum << '\n';
  }
}
