#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using uint = unsigned int;
using rl = double;
const int MAXN = 100009;
const ll INF = 2 * 1000000000LL * 1000000000LL;
int n, m;
struct Monst {
  int mH, r;
  int cntO;
  bool wasKillable;
} v[MAXN];
using tlii = tuple<ll, int, int, int>;
priority_queue<tlii, vector<tlii>, std::greater<tlii>> ev;
ll bounty, increase, damage;
int main() {
  scanf("%d %d", &n, &m);
  scanf("%lld %lld %lld", &bounty, &increase, &damage);
  for (int i = 1; i <= n; i++) {
    int sH;
    scanf("%d %d %d", &v[i].mH, &sH, &v[i].r);
    ev.push({0, i, sH, 0});
  }
  for (int i = 0; i < m; i++) {
    int t, e, h;
    scanf("%d %d %d", &t, &e, &h);
    ev.push({t, e, h, 0});
  }
  ev.push({INF, 0, 0, 0});
  int killable = 0;
  while (ev.empty() == false) {
    ll t;
    int e, h, idx;
    tie(t, e, h, idx) = ev.top();
    if (t != 0) break;
    ev.pop();
    v[e].wasKillable = false;
    v[e].cntO++;
    if (h <= damage) {
      killable++;
      v[e].wasKillable = true;
      if (v[e].r > 0 && v[e].mH > damage) {
        ll dy = damage + 1 - h;
        ll dt = (dy + v[e].r - 1) / v[e].r;
        ev.push({t + dt, e, damage + 1, v[e].cntO});
      }
    }
  }
  ll bestSum = 0;
  ll lTime = 0;
  while (ev.empty() == false) {
    ll t;
    int e, h, idx;
    tie(t, e, h, idx) = ev.top();
    ;
    ;
    ;
    ;
    ;
    ev.pop();
    if (t == INF) {
      if (killable > 0) {
        if (increase > 0)
          bestSum = -1;
        else {
          bestSum = max(bestSum, killable * bounty);
        }
      }
      break;
    }
    if (idx != 0 && v[e].cntO != idx) continue;
    if (lTime != t) {
      lTime = t;
      bestSum = max(bestSum, killable * (bounty + (increase * (ll)(t - 1))));
    }
    v[e].cntO++;
    if (h <= damage) {
      if (v[e].wasKillable == false) killable++;
      v[e].wasKillable = true;
      if (v[e].r > 0 && v[e].mH > damage) {
        ll dy = damage + 1 - h;
        ll dt = (dy + v[e].r - 1) / v[e].r;
        ev.push({t + dt, e, damage + 1, v[e].cntO});
      }
    } else {
      if (v[e].wasKillable) killable--;
      v[e].wasKillable = false;
    }
  }
  printf("%lld\n", bestSum);
}
