#include <bits/stdc++.h>
using namespace std;
int n, m;
long long sol, bounty, increase, damage, nr;
struct enemy {
  long long mh, sh, rh;
} a[100002];
vector<pair<long long, long long> > HU[100002], T;
bool anytime = false;
long long max(long long a, long long b) {
  if (a > b) return a;
  return b;
}
int main() {
  scanf("%d%d", &n, &m);
  scanf("%I64d%I64d%I64d", &bounty, &increase, &damage);
  for (int i = 1; i <= n; i++) {
    scanf("%I64d%I64d%I64d", &a[i].mh, &a[i].sh, &a[i].rh);
    if (a[i].mh <= damage and increase > 0) anytime = true;
  }
  long long t, en, h;
  for (int i = 1; i <= m; i++) {
    scanf("%I64d%I64d%I64d", &t, &en, &h);
    HU[en].push_back(make_pair(t, h));
  }
  for (int i = 1; i <= n; i++)
    if (HU[i].size() > 0 and a[i].rh == 0 and
        HU[i][HU[i].size() - 1].second <= damage and increase > 0)
      anytime = true;
  if (anytime)
    cout << "-1";
  else {
    long long starting_time, finishing_time, starting_heal;
    for (int i = 1; i <= n; i++) {
      if (a[i].mh <= damage)
        nr = nr + 1;
      else {
        HU[i].push_back(make_pair(2e9, 2e9));
        sort(HU[i].begin(), HU[i].end());
        starting_time = 0;
        starting_heal = a[i].sh;
        for (unsigned int j = 0; j < HU[i].size(); j++) {
          finishing_time = HU[i][j].first;
          if (starting_heal <= damage) {
            if (starting_heal + (finishing_time - starting_time) * a[i].rh >
                damage) {
              finishing_time =
                  starting_time + (damage - starting_heal) / a[i].rh;
            } else
              finishing_time = finishing_time - 1;
            T.push_back(make_pair(starting_time, finishing_time));
          }
          starting_heal = HU[i][j].second;
          starting_time = HU[i][j].first;
        }
      }
    }
    int p = T.size();
    vector<long long> t1, t2;
    if (p == 0)
      cout << nr * bounty;
    else {
      for (int i = 0; i < p; i++) {
        t1.push_back(T[i].first);
        t2.push_back(T[i].second);
      }
      sort(t1.begin(), t1.end());
      sort(t2.begin(), t2.end());
      t1.push_back(2e9);
      sol = nr * bounty;
      int i = 0, j = 0;
      while (j < p) {
        if (t1[i] <= t2[j]) {
          nr = nr + 1;
          i = i + 1;
        } else {
          sol = max(sol, nr * (bounty + increase * t2[j]));
          nr = nr - 1;
          j = j + 1;
        }
      }
      cout << sol;
    }
  }
  return 0;
}
