#include <bits/stdc++.h>
using namespace std;
const int inf = 1 << 30;
const int N = 100100;
struct tt {
  int mx, st_h, reg, id;
};
tt ene[N];
struct ttt {
  int sec, num, nw;
};
ttt upd[N];
long long last[N];
bool comp(ttt a, ttt b) { return a.sec < b.sec; }
bool comp2(tt a, tt b) { return a.id < b.id; }
int n, m, q;
long long b, inc;
int d;
vector<pair<long long, long long> > swip;
int main() {
  scanf("%d %d", &n, &m);
  scanf("%lld %lld %d", &b, &inc, &d);
  bool sol = 1;
  for (int i = 0; i <= n + 4; i++) last[i] = 1LL * inf * inf;
  for (int i = 0; i < n; i++) {
    scanf("%d %d %d", &(ene[i].mx), &(ene[i].st_h), &(ene[i].reg));
    if (ene[i].mx <= d && inc > 0) sol = 0;
    ene[i].id = i;
  }
  if (!sol) {
    printf("-1");
    return 0;
  }
  sort(ene, ene + n, comp2);
  for (int i = 0; i < m; i++) {
    scanf("%d %d %d", &(upd[i].sec), &(upd[i].num), &(upd[i].nw));
  }
  sort(upd, upd + m, comp);
  for (int i = m - 1; i >= 0; i--) {
    if (upd[i].nw > d) {
      last[upd[i].num - 1] = upd[i].sec;
      continue;
    }
    int id = upd[i].num - 1;
    if (last[id] > inf && upd[i].nw <= d && ene[id].reg == 0 && inc > 0)
      sol = 0;
    int mx = min(ene[id].mx, d);
    mx -= upd[i].nw;
    long long s = 0;
    if (ene[id].reg != 0) {
      s = mx / ene[id].reg;
      s += upd[i].sec;
    } else
      s = last[id];
    s = min(last[id] - 1, s);
    swip.push_back({upd[i].sec, +1});
    swip.push_back({s + 1, -1});
    last[id] = upd[i].sec;
  }
  for (int i = 0; i < n; i++) {
    if (last[i] > inf && ene[i].st_h <= d && ene[i].reg == 0 && inc > 0)
      sol = 0;
    if (ene[i].st_h > d) continue;
    int id = ene[i].id;
    int mx = min(ene[i].mx, d);
    mx -= ene[i].st_h;
    long long s = 0;
    if (ene[id].reg != 0) {
      s = mx / ene[id].reg;
    } else
      s = last[id];
    s = min(last[id] - 1, s);
    swip.push_back({0, +1});
    swip.push_back({s + 1, -1});
    last[id] = 0;
  }
  if (!sol) {
    printf("-1");
    return 0;
  }
  sort(swip.begin(), swip.end());
  long long ANS = 0;
  int diff = 0;
  for (auto x : swip) {
    diff += x.second;
    if (x.second == -1) {
      long long add = 1LL * b + (1LL * (x.first - 1) * inc);
      ANS = max(1LL * (diff + 1) * add, ANS);
    } else {
      long long add = 1LL * b + (1LL * x.first * inc);
      ANS = max(1LL * diff * add, ANS);
    }
  }
  printf("%lld", ANS);
  return 0;
}
