#include <bits/stdc++.h>
using namespace std;
const int mn = 1e5 + 5;
long long n, m;
long long bounty, increase, damage;
struct node {
  int u, v, w;
  bool operator<(const node &rhs) const { return u < rhs.u; }
} p[mn];
vector<node> v[mn];
map<int, int> q;
bool isin[mn];
int nowi[mn];
int main() {
  ios::sync_with_stdio(0);
  cin >> n >> m;
  cin >> bounty >> increase >> damage;
  bool flag = 0;
  for (int i = 1; i <= n; i++) {
    cin >> p[i].u >> p[i].v >> p[i].w;
    if (increase && p[i].u <= damage) flag = 1;
  }
  for (int i = 1; i <= m; i++) {
    node c;
    cin >> c.u >> c.v >> c.w;
    v[c.v].push_back(c);
  }
  for (int i = 1; i <= n; i++) sort(v[i].begin(), v[i].end());
  for (int i = 1; i <= n; i++) {
    if (increase && p[i].w == 0) {
      if (v[i].size() == 0) {
        if (p[i].v <= damage) flag = 1;
        continue;
      }
      node u = *v[i].rbegin();
      if (u.w <= damage) flag = 1;
    }
  }
  if (flag) {
    cout << "-1";
    return 0;
  }
  long long nowin = 0;
  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    long long nowt = 0, nowh = p[i].v;
    if (p[i].v <= damage) {
      q[0]++, isin[i] = 1;
    }
    long long outtime = 0;
    if (p[i].w == 0 || !isin[i])
      outtime = 2e9 + 9;
    else {
      outtime = (damage - nowh) / p[i].w + nowt + 1;
    }
    if ((v[i].size() == 0 || outtime < v[i][0].u) && outtime <= 2e9) {
      q[outtime - 1] += 0;
      q[outtime]--;
      isin[i] = 0;
    }
    for (int j = 0; j < v[i].size(); j++) {
      if (v[i][j].w > damage && isin[i]) {
        isin[i] = 0;
        q[v[i][j].u - 1] -= 0;
        q[v[i][j].u]--;
        continue;
      }
      if (!isin[i] && v[i][j].w > damage) {
        continue;
      }
      if (v[i][j].w <= damage) {
        nowt = v[i][j].u;
        nowh = v[i][j].w;
        if (!isin[i]) {
          isin[i] = 1;
          q[nowt - 1] += 0;
          q[nowt]++;
        }
      }
      if (p[i].w == 0 || !isin[i])
        outtime = 2e9 + 9;
      else {
        outtime = (damage - nowh) / p[i].w + nowt + 1;
      }
      if ((j == v[i].size() - 1 || outtime < v[i][j + 1].u) && outtime <= 2e9) {
        q[outtime - 1] += 0;
        q[outtime]--;
        isin[i] = 0;
      }
    }
  }
  ans = nowin * bounty;
  for (auto &i : q) {
    nowin += i.second;
    ans = max(ans, nowin * (bounty + 1ll * i.first * increase));
  }
  cout << ans;
  return 0;
}
