#include <bits/stdc++.h>
using std::cerr;
using std::cin;
using std::max;
using std::min;
int n, m, stv, atk, inc, Cn, cnt, tot, so[100005 << 2], Sum[100005 << 2];
long long ans;
std::vector<int> S[100005];
struct info1 {
  int Max, h, v;
} A[100005];
struct info2 {
  int t, id, v;
  friend bool operator<(info2 t1, info2 t2) {
    return t1.id < t2.id || t1.id == t2.id && t1.t < t2.t;
  }
} B[100005];
struct node {
  int l, r;
} C[100005 << 1];
void work(int id, int v, int tl, int tr) {
  if (tl > tr || v > atk) return;
  if (!A[id].v) return void(C[++Cn] = {tl, tr});
  C[++Cn] = {tl, min(tr, tl + (atk - v) / A[id].v)};
}
void Solve(int id) {
  if (!S[id].size())
    return work(id, A[id].h, 0, 1e9);
  else
    work(id, A[id].h, 0, B[S[id][0]].t - 1);
  int tmp;
  for (int i = 0; i < S[id].size() - 1; i++)
    tmp = S[id][i], work(id, B[tmp].v, B[tmp].t, B[S[id][i + 1]].t - 1);
  tmp = S[id][S[id].size() - 1];
  work(id, B[tmp].v, B[tmp].t, 1e9);
}
int main() {
  scanf("%d%d%d%d%d", &n, &m, &stv, &inc, &atk);
  for (int i = 1; i <= n; i++) {
    scanf("%d%d%d", &A[i].Max, &A[i].h, &A[i].v);
    if (inc && (A[i].Max <= atk || (A[i].h <= atk && !A[i].v)))
      return puts("-1"), 0;
  }
  for (int i = 1; i <= m; i++) scanf("%d%d%d", &B[i].t, &B[i].id, &B[i].v);
  std::sort(B + 1, B + 1 + m);
  for (int i = 1; i <= m; i++) S[B[i].id].push_back(i);
  for (int i = 1; i <= n; i++) Solve(i);
  for (int i = 1; i <= Cn; i++) so[++cnt] = C[i].l, so[++cnt] = C[i].r;
  std::sort(so + 1, so + 1 + cnt);
  tot = std::unique(so + 1, so + 1 + cnt) - so - 1;
  for (int i = 1; i <= Cn; i++)
    C[i].l = std::lower_bound(so + 1, so + 1 + tot, C[i].l) - so,
    C[i].r = std::lower_bound(so + 1, so + 1 + tot, C[i].r) - so, Sum[C[i].l]++,
    Sum[C[i].r + 1]--;
  for (int i = 1; i <= tot; i++)
    Sum[i] += Sum[i - 1],
        ans = max(ans, (long long)Sum[i] * (stv + (long long)so[i] * inc));
  printf("%lld\n", ans);
  return 0;
}
