#include <bits/stdc++.h>
using namespace std;
const int INF = 2e9;
const int MAX = 100000;
const long long lim = 1e18;
struct Enemy {
  long long mxH;
  long long hlth;
  long long reg;
  vector<pair<long long, int>> v;
  void generate(long long strt, long long dmg) {
    if (!v.size() && hlth <= dmg) {
      v.push_back(make_pair(strt, 1));
      if (mxH > dmg && reg > 0)
        v.push_back(make_pair(strt + (dmg - hlth) / reg, 0));
      else if (reg == 0 || mxH == dmg)
        v.push_back(make_pair(INF, 0));
    } else if (v.size()) {
      if (strt <= v.back().first) {
        v.back() = make_pair(strt - 1, 0);
      }
      if (hlth <= dmg) {
        v.push_back(make_pair(strt, 1));
        if (mxH > dmg && reg > 0)
          v.push_back(make_pair(strt + (dmg - hlth) / reg, 0));
        else if (reg == 0 || mxH == dmg)
          v.push_back(make_pair(INF, 0));
      }
    }
  }
  bool inf(long long dmg, long long inc) {
    if (reg == 0 && hlth <= dmg && inc) return true;
    if (mxH <= dmg && inc) return true;
    return false;
  }
};
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, m;
  while (cin >> n >> m) {
    long long bnt, inc, dmg;
    cin >> bnt >> inc >> dmg;
    vector<Enemy> v(n);
    for (int i = 0; i < n; i++) {
      cin >> v[i].mxH >> v[i].hlth >> v[i].reg;
      v[i].generate(0ll, dmg);
    }
    vector<pair<long long, pair<int, long long>>> q(m);
    for (int i = 0; i < m; i++)
      cin >> q[i].first >> q[i].second.first >> q[i].second.second;
    sort(q.begin(), q.end());
    for (int i = 0; i < m; i++) {
      long long t = q[i].first;
      int e = q[i].second.first - 1;
      long long nh = q[i].second.second;
      v[e].hlth = nh;
      v[e].generate(t, dmg);
    }
    for (int i = 0; i < n; i++) {
      if (v[i].inf(dmg, inc)) {
        cout << -1 << "\n";
        return 0;
      }
    }
    map<long long, pair<long long, long long>> mp;
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < v[i].v.size(); j++) {
        long long t = v[i].v[j].first;
        int st = v[i].v[j].second;
        if (st == 1)
          mp[t].first++;
        else
          mp[t].second++;
      }
    }
    long long cnt = 0;
    long long res = 0;
    for (map<long long, pair<long long, long long>>::iterator it = mp.begin();
         it != mp.end(); it++) {
      long long t = it->first;
      long long gn = it->second.first;
      long long ls = it->second.second;
      cnt += gn;
      res = max(res, cnt * (bnt + t * inc));
      cnt -= ls;
    }
    cout << res << "\n";
  }
  return 0;
}
