#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
long long mx[N], stt[N], ret[N];
long long ti[N];
bool cnt[N];
int main() {
  ios::sync_with_stdio(false);
  cin.tie();
  cout.tie();
  long long n, m;
  cin >> n >> m;
  long long b, inc, dmg;
  cin >> b >> inc >> dmg;
  int c = 0;
  set<pair<long long, pair<int, int> > > st;
  long long CC = 0;
  for (int i = 0; i < n; i++) {
    cin >> mx[i] >> stt[i] >> ret[i];
    if (mx[i] <= dmg) c = 1;
    if (stt[i] > dmg) continue;
    cnt[i] = 1;
    CC++;
    long long dif = (dmg + 1) - stt[i];
    if (ret[i] != 0) {
      dif = (dif + ret[i] - 1) / ret[i];
      ti[i] = dif;
    } else
      ti[i] = 1e15;
    st.insert({ti[i], {i, -1}});
  }
  for (int i = 0; i < m; i++) {
    long long a, b, c;
    cin >> a >> b >> c;
    b--;
    st.insert({a, {b, c}});
  }
  if (c && inc) {
    if (inc) cout << -1 << endl;
  } else {
    long long ans = CC * b;
    while (st.size() > 0) {
      pair<long long, pair<int, int> > p = *st.begin();
      st.erase(st.begin());
      long long t = p.first;
      int idx = p.second.first;
      if (t >= 1e15 - 1) {
        if (inc) ans = -1;
        break;
      }
      ans = max(ans, CC * (b + inc * (t - 1LL)));
      if (p.second.second > 0) {
        if (cnt[idx]) {
          st.erase(st.find(make_pair(ti[idx], make_pair(idx, -1))));
          if (p.second.second > dmg) {
            cnt[idx] = 0;
            CC--;
          } else {
            long long dif = (dmg + 1) - p.second.second;
            if (ret[idx] != 0) {
              dif = (dif + ret[idx] - 1) / ret[idx];
              ti[idx] = t + dif;
            } else {
              ti[idx] = 1e15;
            }
            st.insert({ti[idx], {idx, -1}});
          }
        } else {
          if (p.second.second > dmg) {
          } else {
            CC++;
            cnt[idx] = 1;
            long long dif = (dmg + 1) - p.second.second;
            if (ret[idx] != 0) {
              dif = (dif + ret[idx] - 1) / ret[idx];
              ti[idx] = t + dif;
            } else {
              ti[idx] = 1e15;
            }
            st.insert({ti[idx], {idx, -1}});
          }
        }
      } else {
        if (cnt[idx]) {
          cnt[idx] = 0;
          CC--;
        }
      }
    }
    cout << ans << endl;
  }
  return 0;
}
