#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
constexpr ll MAXN = 100000 + 5;
int n, m;
ll bot, inc, dam;
ll maxh[MAXN];
ll starth[MAXN];
ll regen[MAXN];
vector<pair<ll, ll>> up[MAXN];
unordered_map<ll, ll> mt;
unordered_set<ll> tpoints;
void gen(const int id) {
  const ll mh = maxh[id];
  const ll reg = regen[id];
  auto &cup = up[id];
  sort(cup.begin(), cup.end());
  int in = 0;
  ll prect = -1;
  ll prech = -1;
  int i = 0;
  vector<pair<ll, ll>> cal;
  while (i < cup.size() || cal.size()) {
    if (cal.size()) {
      ll prect = cal[0].first;
      ll prech = cal[0].second;
      cal.clear();
      if (i >= cup.size() || prect < cup[i].first) {
        if (prech <= dam) {
          tpoints.insert(prect);
          if (reg) {
            prect++;
            prech = min(prech + reg, mh);
            cal.emplace_back(prect, prech);
          }
        } else {
          mt[prect]--;
          in = 0;
        }
      }
      continue;
    }
    auto const p = cup[i];
    const ll ct = p.first;
    const ll ch = p.second;
    if (ch < dam) {
      if (in == 1) {
      } else {
        in = 1;
        mt[ct]++;
        tpoints.insert(ct);
      }
      if (reg) {
        prect = ct + (dam - ch) / reg;
        prech = ch + (prect - ct) * reg;
        cal.emplace_back(prect, prech);
      }
    } else if (ch > dam) {
      if (in == 1) {
        tpoints.insert(ct - 1);
        mt[ct]--;
        in = 0;
      }
    } else if (ch == dam) {
      if (in == 0) {
        in = 1;
        mt[ct]++;
        tpoints.insert(ct);
      } else {
        tpoints.insert(ct);
      }
      if (reg) {
        prect = ct + 1;
        prech = min(mh, prech + reg);
        cal.emplace_back(prect, prech);
      }
    }
    i++;
  }
}
int main() {
  ios::sync_with_stdio(false);
  int inf = 0;
  cin >> n >> m;
  cin >> bot >> inc >> dam;
  ll base = 0;
  for (int i = 1; i <= n; ++i) {
    cin >> maxh[i] >> starth[i] >> regen[i];
    if (maxh[i] <= dam) {
      if (inc > 0) {
        inf = 1;
      } else
        base++;
    }
    up[i].emplace_back(0, starth[i]);
  }
  for (int i = 0; i < m; ++i) {
    int t, id, h;
    cin >> t >> id >> h;
    up[id].emplace_back(t, h);
  }
  if (inf) {
    cout << -1;
    return 0;
  }
  for (int i = 1; i <= n; ++i) {
    if (maxh[i] > dam) gen(i);
  }
  for (auto const &p : mt) {
    tpoints.insert(p.first);
  }
  ll ret = 0;
  vector<pair<ll, ll>> vm(mt.begin(), mt.end());
  sort(vm.begin(), vm.end());
  auto mit = vm.begin();
  vector<ll> tt(tpoints.begin(), tpoints.end());
  sort(tt.begin(), tt.end());
  for (auto t : tt) {
    while (mit != vm.end() && mit->first <= t) {
      base += mit->second;
      ++mit;
    }
    ret = max(ret, base * (bot + inc * t));
  }
  ret = max(ret, base * (bot));
  if (base > 0 && inc > 0) {
    inf = 1;
  }
  if (inf) {
    cout << -1;
    return 0;
  }
  cout << ret;
}
