#include <bits/stdc++.h>
using namespace std;
const long long INF = 0x7fffffff;
const long long M = 100100;
struct Node {
  long long Max_health, Start_health, Regen;
  vector<pair<long long, long long> > Update;
} Enemy[M];
long long n, m, Bounty, Increase, Damage, Time, Who, Health, Start_health;
long long ans;
map<long long, long long> cal;
vector<long long> tim;
signed main(void) {
  scanf("%lld%lld", &n, &m);
  scanf("%lld%lld%lld", &Bounty, &Increase, &Damage);
  for (long long i = 1; i <= n; i++) {
    scanf("%lld%lld%lld", &Enemy[i].Max_health, &Start_health, &Enemy[i].Regen);
    if (Enemy[i].Max_health <= Damage && Increase) {
      puts("-1");
      return 0;
    }
    Enemy[i].Update.push_back(make_pair(0, Start_health));
  }
  for (long long i = 1; i <= m; i++) {
    scanf("%lld%lld%lld", &Time, &Who, &Health);
    Enemy[Who].Update.push_back(make_pair(Time, Health));
  }
  for (long long i = 1; i <= n; i++) {
    Node To = Enemy[i];
    sort(To.Update.begin(), To.Update.end());
    long long siz = To.Update.size();
    for (long long j = 0; j < siz; j++) {
      pair<long long, long long> now = To.Update[j];
      if (now.second > Damage) continue;
      if (To.Regen == 0) {
        if (Increase) {
          puts("-1");
          return 0;
        }
        cal[now.first]++;
        tim.push_back(now.first);
        if (j != siz - 1) {
          long long lim = To.Update[j + 1].first;
          cal[lim]--;
          tim.push_back(lim - 1);
          tim.push_back(lim);
        } else
          cal[INF]--, tim.push_back(INF);
        continue;
      }
      long long lim = now.first + (Damage - now.second) / To.Regen;
      if (j != siz - 1) lim = min(lim, To.Update[j + 1].first - 1);
      cal[now.first]++;
      cal[lim + 1]--;
      tim.push_back(now.first);
      tim.push_back(lim);
      tim.push_back(lim + 1);
    }
  }
  sort(tim.begin(), tim.end());
  tim.erase(unique(tim.begin(), tim.end()), tim.end());
  long long now = 0;
  for (long long i = 0; i < tim.size(); i++) {
    now += cal[tim[i]];
    ans = max(ans, 1LL * (tim[i] * Increase + Bounty) * now);
  }
  printf("%lld\n", ans);
  return 0;
}
