#include <bits/stdc++.h>
using namespace std;
const int INF = (int)(1e9 + 1337);
struct enemy {
  long long max_health, start_health, regen;
};
struct event {
  long long time, new_health;
  int enemy;
};
bool operator<(const event& a, const event& b) { return a.time < b.time; }
struct my_event {
  long long time;
  int type;
  int enemy;
  int bound_event;
  bool was_upper;
};
bool operator<(const my_event& a, const my_event& b) { return a.time > b.time; }
int n, m;
long long bounty, incr, damage;
enemy v[100010];
vector<event> ve[100010];
long long inf_health[100010];
priority_queue<my_event> q;
long long when_kill(enemy en, long long cur_health) {
  if (cur_health > damage) {
    return -1;
  }
  if (en.regen == 0) {
    return INF;
  }
  long long dt = damage - cur_health;
  long long creg = dt / en.regen;
  return creg;
}
void solve() {
  cin >> n >> m;
  cin >> bounty >> incr >> damage;
  for (int i = 1; i <= n; ++i) {
    cin >> v[i].max_health >> v[i].start_health >> v[i].regen;
    if (v[i].regen == 0) {
      inf_health[i] = v[i].start_health;
    } else {
      inf_health[i] = v[i].max_health;
    }
    event e;
    e.time = 0;
    e.enemy = i;
    e.new_health = v[i].start_health;
    ve[i].push_back(e);
  }
  for (int i = 1; i <= m; ++i) {
    event e;
    cin >> e.time >> e.enemy >> e.new_health;
    ve[e.enemy].push_back(e);
  }
  for (int i = 1; i <= n; ++i) {
    sort(ve[i].begin(), ve[i].end());
    if (!ve[i].empty() && v[i].regen == 0)
      inf_health[i] = ve[i].back().new_health;
  }
  for (int i = 1; i <= n; ++i) {
    if (inf_health[i] <= damage && incr > 0) {
      cout << "-1";
      return;
    }
  }
  long long last = 0;
  long long ctr = 0;
  long long ans = 0;
  for (int i = 1; i <= n; ++i) {
    my_event e;
    e.enemy = i;
    e.time = 0;
    e.type = 2;
    e.bound_event = 0;
    e.was_upper = true;
    q.push(e);
  }
  while (!q.empty()) {
    my_event e = q.top();
    q.pop();
    if (e.time != last) {
      ans = max(ans, (bounty + last * incr) * ctr);
      last = e.time;
    }
    if (e.type <= 1) {
      ctr += e.type;
    } else {
      int i = e.enemy;
      long long health = ve[i][e.bound_event].new_health;
      long long wk = when_kill(v[i], health) + e.time;
      int nxt = e.bound_event + 1;
      if ((nxt >= (int)ve[i].size() && e.time <= wk) ||
          (e.time <= wk && wk < ve[i][nxt].time)) {
        my_event ne;
        if (wk > e.time) {
          ne.enemy = i;
          ne.time = wk;
          ne.type = 0;
          ne.was_upper = health > damage;
          q.push(ne);
        }
        ne.enemy = i;
        ne.time = wk + 1;
        ne.type = -1;
        ne.was_upper = health > damage;
        q.push(ne);
      } else if (nxt < (int)ve[i].size()) {
        long long dtime = ve[i][nxt].time - 1 - e.time;
        long long pre_health = health + dtime * v[i].regen;
        if (pre_health <= damage && dtime > 0) {
          my_event ne;
          ne.enemy = i;
          ne.time = dtime + e.time;
          ne.type = 0;
          ne.was_upper = false;
          q.push(ne);
        }
      }
      if (nxt < (int)ve[i].size()) {
        my_event ne;
        ne.enemy = i;
        ne.time = ve[i][nxt].time;
        ne.bound_event = nxt;
        ne.type = 2;
        long long nhealth = health + (ne.time - e.time - 1) * v[i].regen;
        ne.was_upper = nhealth > damage;
        q.push(ne);
      }
      if (health <= damage && e.was_upper) {
        ++ctr;
      }
      if (health > damage && !e.was_upper) {
        --ctr;
      }
    }
  }
  ans = max(ans, (bounty + last * incr) * ctr);
  cout << ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  solve();
  return 0;
}
