#include <bits/stdc++.h>
using namespace std;
template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  os << '{';
  for (int i = (0), __i = (((int)(vec).size())); i < __i; i++) {
    os << vec[i];
    if (i + 1 != ((int)(vec).size())) os << ',';
  }
  os << '}';
  return os;
}
template <class T1, class T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &par) {
  os << '(' << par.first << ',' << par.second << ')';
  return os;
}
int gcd(int x, int y) { return y ? gcd(y, x % y) : abs(x); }
template <class T>
T sqr(T x) {
  return x * x;
}
const long long MOD = 1e9 + 7;
long long bin_pow(long long base, long long p) {
  if (p == 1) return base;
  if (p % 2 == 0) {
    long long t = bin_pow(base, p / 2);
    return t * t % MOD;
  } else
    return bin_pow(base, p - 1) * base % MOD;
}
long long inverse_element(long long x) { return bin_pow(x, MOD - 2); }
long long add(long long a, long long b) { return (a + b) % MOD; }
long long sub(long long a, long long b) { return (MOD + a - b) % MOD; }
long long divide(long long a, long long b) {
  return a * inverse_element(b) % MOD;
}
long long mult(long long a, long long b) { return (a * b) % MOD; }
long long enemy[101010][3];
vector<pair<long long, long long>> change[101010];
map<long long, int> tc;
long long tcr[505050];
long long sgm[505050];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  vector<long long> times;
  times.push_back(0);
  times.push_back(1000000000000LL);
  long long n, m;
  cin >> n >> m;
  long long bounty, damage, increase;
  cin >> bounty >> increase >> damage;
  for (int i = (0), __i = (n); i < __i; i++) {
    cin >> enemy[i][0] >> enemy[i][1] >> enemy[i][2];
    if (enemy[i][0] <= damage && increase > 0) {
      cout << -1;
      return 0;
    }
    if (enemy[i][2] > 0 && damage >= enemy[i][1] && enemy[i][0] > damage)
      times.push_back((damage - enemy[i][1]) / enemy[i][2]);
    change[i].push_back({0, enemy[i][1]});
  }
  for (int i = (0), __i = (m); i < __i; i++) {
    long long tm, enm, hlth;
    cin >> tm >> enm >> hlth;
    enm--;
    times.push_back(tm);
    times.push_back(tm - 1);
    if (enemy[enm][2] > 0 && damage >= hlth && enemy[enm][0] > damage)
      times.push_back(tm + (damage - hlth) / enemy[enm][2]);
    change[enm].push_back({tm, hlth});
  }
  sort((times).begin(), (times).end());
  for (int i = (0), __i = (n); i < __i; i++)
    sort((change[i]).begin(), (change[i]).end());
  long long tcount = 1;
  tcr[tcount] = times[0];
  tc[times[0]] = tcount++;
  for (int i = (1), __i = (times.size()); i < __i; i++) {
    if (times[i] != times[i - 1]) {
      tcr[tcount] = times[i];
      tc[times[i]] = tcount++;
    }
  }
  for (int i = (0), __i = (n); i < __i; i++) {
    auto last = change[i][((int)(change[i]).size()) - 1];
    if (last.second <= damage) {
      if (enemy[i][2] == 0 || enemy[i][0] <= damage) {
        sgm[tcount - 1]++;
        sgm[tc[last.first] - 1]--;
      } else {
        sgm[tc[last.first + (damage - last.second) / enemy[i][2]]]++;
        sgm[tc[last.first] - 1]--;
      }
    }
    for (int j = ((int)(change[i]).size()) - 2; j >= 0; j--) {
      auto cur = change[i][j];
      auto nxt = change[i][j + 1];
      if (cur.second <= damage) {
        if (enemy[i][2] == 0 || enemy[i][0] <= damage) {
          sgm[tc[nxt.first] - 1]++;
          sgm[tc[cur.first] - 1]--;
        } else {
          long long endtime =
              min(tc[cur.first + (damage - cur.second) / enemy[i][2]],
                  tc[nxt.first] - 1);
          sgm[endtime]++;
          sgm[tc[cur.first] - 1]--;
        }
      }
    }
  }
  if (increase > 0 && sgm[tcount - 1] > 0) {
    cout << -1;
    return 0;
  }
  for (int i = tcount - 1; i > 0; i--) sgm[i - 1] += sgm[i];
  long long res = 0;
  for (int i = (1), __i = (tcount); i < __i; i++) {
    res = max(res, sgm[i] * (bounty + tcr[i] * increase));
  }
  cout << res;
  return 0;
}
