#include <bits/stdc++.h>
using namespace std;
const int maxn = 100005;
const int maxm = 100005;
struct enemy {
  int start, max, recover;
};
struct change {
  int t, i, h;
  friend bool operator<(change c1, change c2) { return c1.t < c2.t; }
};
int dmg, bty, ics;
int n, m;
enemy e[maxn];
set<pair<int, int> > c[maxn];
set<pair<int, int> > res;
map<int, int> timeline;
int main() {
  cin >> n >> m;
  cin >> bty >> ics >> dmg;
  int cnt = 0;
  for (int i = 1; i <= n; i++) {
    scanf("%d%d%d", &e[i].max, &e[i].start, &e[i].recover);
    if (e[i].start <= dmg) cnt++;
  }
  for (int i = 0; i < m; i++) {
    int t, ei, h;
    scanf("%d%d%d", &t, &ei, &h);
    c[ei].insert(make_pair(t, h));
  }
  for (int i = 1; i <= n; i++) {
    if (e[i].max <= dmg) continue;
    if (c[i].size() == 0) {
      int d = dmg - e[i].start;
      if (d > 0 && e[i].recover > 0) {
        int t = d / e[i].recover + 1;
        if (timeline.count(t) != 0)
          timeline[t] -= 1;
        else
          timeline.insert(make_pair(t, -1));
      }
      continue;
    }
    bool canupdate = false;
    if (e[i].recover > 0) canupdate = true;
    bool kill = false;
    if (e[i].start <= dmg) kill = true;
    int ch = e[i].start;
    int ct = 0;
    set<pair<int, int> >::iterator it = c[i].begin();
    while (it != c[i].end()) {
      pair<int, int> tmp = *it;
      int d = dmg - ch;
      if (d > 0 && canupdate) {
        int t = ct + d / e[i].recover + 1;
        if (t < tmp.first) {
          if (timeline.count(t) != 0)
            timeline[t] += -1;
          else
            timeline.insert(make_pair(t, -1));
          kill = false;
        }
      }
      if (tmp.second <= dmg && kill == false) {
        if (timeline.count(tmp.first) != 0)
          timeline[tmp.first] += 1;
        else
          timeline.insert(make_pair(tmp.first, 1));
        kill = true;
      } else if (tmp.second > dmg && kill == true) {
        if (timeline.count(tmp.first) != 0)
          timeline[tmp.first] += -1;
        else
          timeline.insert(make_pair(tmp.first, -1));
        kill = false;
      }
      ct = tmp.first;
      ch = tmp.second;
      ++it;
    }
    int d = dmg - ch;
    if (d > 0 && canupdate) {
      int t = ct + d / e[i].recover + 1;
      if (timeline.count(t) != 0)
        timeline[t] += -1;
      else
        timeline.insert(make_pair(t, -1));
    }
  }
  map<int, int>::iterator itmap = timeline.begin();
  while (itmap != timeline.end()) {
    res.insert(make_pair(itmap->first, itmap->second));
    ++itmap;
  }
  long long ans = 1LL * cnt * bty;
  int t = 0;
  int cnt1;
  set<pair<int, int> >::iterator it = res.begin();
  while (it != res.end()) {
    pair<int, int> p = *it;
    cnt1 = cnt + p.second;
    ans = max(ans, 1LL * cnt1 * (bty + 1LL * p.first * ics));
    ans = max(ans, 1LL * cnt * (bty + 1ll * (p.first - 1) * ics));
    cnt = cnt1;
    ++it;
  }
  if (cnt > 0 && ics > 0)
    cout << -1 << endl;
  else
    printf("%I64d\n", ans);
  return 0;
}
