#include <bits/stdc++.h>
using namespace std;
const int maxn = 100000 + 10;
long long maxHealth[maxn], startHealth[maxn], regen[maxn];
struct Event {
  long long time, who, health;
  bool operator<(const Event& A) const { return time < A.time; }
};
vector<pair<long long, long long>> d[maxn];
void print(pair<long long, long long> a) {
  cout << a.first << " " << a.second << endl;
}
int main() {
  int n, m;
  long long bountry, increase, damage;
  while (scanf("%d%d", &n, &m) == 2) {
    scanf("%lld%lld%lld", &bountry, &increase, &damage);
    for (int i = 0; i <= n; i++) d[i].clear();
    bool inifitely = false;
    for (int i = 1; i <= n; i++) {
      scanf("%lld%lld%lld", &maxHealth[i], &startHealth[i], &regen[i]);
      if (maxHealth[i] <= damage && increase > 0) {
        inifitely = true;
      }
    }
    vector<Event> event;
    for (int i = 0; i < m; i++) {
      long long t, w, h;
      scanf("%lld%lld%lld", &t, &w, &h);
      event.push_back({t, w, h});
    }
    if (inifitely) {
      puts("-1");
      continue;
    }
    sort(event.begin(), event.end());
    for (int i = 1; i <= n; i++) {
      if (startHealth[i] <= damage) {
        if (regen[i] && maxHealth[i] > damage)
          d[i].push_back({0, (damage - startHealth[i]) / regen[i]});
        else
          d[i].push_back({0, 1e18});
      }
    }
    for (auto e : event) {
      long long who = e.who;
      long long t = e.time;
      long long health = e.health;
      if (d[who].size() == 0) {
        if (health <= damage) {
          if (damage >= maxHealth[who] || regen[who] == 0)
            d[who].push_back({t, 1e18});
          else if (regen[who])
            d[who].push_back({t, t + (damage - health) / regen[who]});
        }
        if (regen[who] == 0 && health <= damage && increase > 0)
          inifitely = true;
        continue;
      }
      pair<long long, long long>& pa = d[who][d[who].size() - 1];
      if (health > damage) {
        if (pa.second >= t) {
          pa.second = t - 1;
        }
      } else {
        if (pa.second < t) {
          if (regen[who] && maxHealth[who] > damage)
            d[who].push_back({t, t + (damage - health) / regen[who]});
          else
            d[who].push_back({t, 1e18});
        } else {
          if (regen[who]) pa.second = t + (damage - health) / regen[who];
        }
      }
      if (regen[who] == 0 && health <= damage && increase > 0) inifitely = true;
    }
    for (int i = 1; i <= n; i++)
      if (d[i].size()) {
        pair<long long, long long> pa = d[i][d[i].size() - 1];
        if (pa.second == 1e18 && increase > 0) inifitely = true;
      }
    if (inifitely) {
      puts("-1");
      continue;
    }
    for (int i = 1; i <= n; i++) {
      for (int j = 0; j + 1 < d[i].size(); i++)
        assert(d[i][j].second < d[i][j + 1].first);
    }
    vector<pair<long long, long long>> Q;
    long long sum = 0;
    for (int i = 1; i <= n; i++)
      if (maxHealth[i] > damage) {
        for (auto e : d[i]) {
          if (e.first <= e.second) {
            Q.push_back({e.first, 1});
            Q.push_back({e.second + 1, -1});
          }
        }
      } else
        sum++;
    sort(Q.begin(), Q.end());
    long long ans = 0, now = 0;
    if (increase == 0) ans = max(ans, sum * bountry);
    for (int i = 0; i < Q.size(); i++) {
      pair<long long, long long> pa = Q[i];
      long long t = pa.first;
      long long tmp = 0;
      bool dis = false;
      if (pa.second == -1) {
        dis = true;
        tmp--;
      } else
        tmp++;
      while (i + 1 != Q.size() && Q[i + 1].first == pa.first) {
        pa = Q[i + 1];
        if (pa.second == -1) {
          dis = true;
          tmp--;
        } else
          tmp++;
        i++;
      }
      if (dis) {
        ans = max(ans, sum * (bountry + increase * (t - 1)));
      }
      sum += tmp;
    }
    printf("%lld\n", ans);
  }
  return 0;
}
