#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
map<long long, int> add, erase;
set<long long> timeline;
vector<pair<long long, int> > V[N];
int max_health[N], regen[N];
int main() {
  int n, m, bounty, increase, damage;
  cin >> n >> m >> bounty >> increase >> damage;
  for (int i = 0; i < n; i++) {
    int h;
    scanf("%d%d%d", &max_health[i], &h, &regen[i]);
    V[i].push_back(make_pair(0, h));
  }
  for (int i = 0; i < m; i++) {
    int t, id, h;
    scanf("%d%d%d", &t, &id, &h);
    V[id - 1].push_back(make_pair(t, h));
  }
  for (int i = 0; i < n; i++) {
    auto& v = V[i];
    sort(v.begin(), v.end());
    if (increase > 0) {
      if (damage >= max_health[i] || (!regen[i] && v.back().second <= damage)) {
        return puts("-1") * 0;
      }
    }
    for (int j = 0; j < v.size(); j++) {
      if (v[j].second > damage) continue;
      add[v[j].first]++;
      long long interval = 2e9;
      if (j != v.size() - 1)
        interval = min(interval, v[j + 1].first - v[j].first - 1);
      if (regen[i])
        interval = min(interval, 1LL * (damage - v[j].second) / regen[i]);
      erase[v[j].first + interval]++;
      timeline.insert(v[j].first);
      timeline.insert(v[j].first + interval);
    }
  }
  long long ans = 0, cnt = 0;
  for (long long x : timeline) {
    cnt += add[x];
    ans = max(ans, cnt * (bounty + x * increase));
    cnt -= erase[x];
  }
  cout << ans << endl;
  return 0;
}
