#include <bits/stdc++.h>
bool debug = 0;
const double PI = acos(-1.0);
const double eps = 1e-9;
using namespace std;
map<long long, vector<pair<int, int> > > ev;
long long vida[100100], start[100100], regen[100100];
int n, m;
long long bounty, dano, inc;
bool vivo[100100];
long long swp() {
  long long res = 0;
  long long cnt = 0;
  for (auto j = ev.begin(); j != ev.end(); j++) {
    long long t = j->first;
    if (debug)
      cout << "t"
           << " = " << (t) << endl;
    res = max(res, (bounty + t * inc) * cnt);
    for (pair<int, int> now : j->second) {
      if (now.second == -1) continue;
      if (vivo[now.first] == 0) {
        cnt++;
        vivo[now.first] = 1;
      }
    }
    if (debug) cout << endl;
    res = max(res, (bounty + t * inc) * cnt);
    for (pair<int, int> now : j->second) {
      if (now.second == 1) continue;
      if (vivo[now.first] == 1) {
        cnt--;
        vivo[now.first] = 0;
      }
    }
    res = max(res, (bounty + t * inc) * cnt);
    if (debug)
      cout << "res"
           << " = " << (res) << endl;
    if (debug) cout << endl;
  }
  return res;
}
int main() {
  scanf("%d %d", &n, &m);
  scanf("%lld %lld %lld", &bounty, &inc, &dano);
  vector<pair<long long, long long> > v[100100];
  for (int i = 0; i < n; i++) {
    scanf("%lld %lld %lld", &vida[i], &start[i], &regen[i]);
    v[i].push_back({0, start[i]});
  }
  long long a, b, c;
  for (int i = 0; i < m; i++) {
    scanf("%lld %lld %lld", &a, &b, &c);
    b--;
    v[b].push_back({a, c});
  }
  for (int i = 0; i < n; i++) {
    sort(v[i].begin(), v[i].end());
  }
  int ultvida[100100];
  for (int i = 0; i < n; i++) {
    int who = i;
    for (int j = 0; j < v[i].size(); j++) {
      long long t = v[i][j].first;
      long long h = v[i][j].second;
      ultvida[who] = h;
      if (h > dano) {
        ev[t - 1].push_back({who, -1});
      } else {
        if (vida[who] <= dano or regen[who] == 0) {
          ev[t].push_back({who, 1});
        } else {
          ev[t].push_back({who, 1});
          long long tt = t + (dano - h) / regen[who];
          if (j + 1 == v[i].size() or v[i][j + 1].first > tt) {
            ev[tt].push_back({who, -1});
          }
        }
      }
    }
  }
  for (int i = 0; i < n; i++) {
    if (inc == 0) break;
    if ((ultvida[i] <= dano and regen[i] == 0) or vida[i] <= dano) {
      cout << -1 << endl;
      return 0;
    }
  }
  cout << swp() << endl;
  return 0;
}
