#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1);
const long long INF = 0x3f3f3f3f3f3f3f3f;
const long long inf = 0xc0c0c0c0c0c0c0c0;
const int MAX = 5e5 + 10;
const int MAXE = 1e5 + 7;
long long bounty, increase, damage;
long long N, M;
long long max_health[MAXE], regen[MAXE];
struct update {
  long long time, health;
  update(long long t = 0, long long h = 0) {
    time = t;
    health = h;
  }
};
bool operator<(update u1, update u2) { return u1.time < u2.time; }
vector<update> U[MAXE];
struct node {
  long long op, time;
};
bool operator<(node n1, node n2) {
  if (n1.time != n2.time)
    return n1.time > n2.time;
  else
    return n1.op < n2.op;
}
node Arr[MAX];
int nodeCnt;
void add(long long from, long long to) {
  node n;
  n.op = 1;
  n.time = to;
  Arr[nodeCnt++] = n;
  n.op = -1;
  n.time = from - 1;
  Arr[nodeCnt++] = n;
}
void getAns() {
  long long ans = 0;
  long long tool = 0;
  sort(Arr, Arr + nodeCnt);
  for (int i = 0; i < nodeCnt; i++) {
    if (Arr[i].time == INF && Arr[i].op == 1 && increase) {
      ans = -1;
      break;
    }
    tool += Arr[i].op;
    long long temp = tool * (bounty + increase * Arr[i].time);
    ans = max(ans, temp);
  }
  cout << ans;
}
long long toolI[MAXE];
int init() {
  nodeCnt = 0;
  scanf("%lld%lld%lld%lld%lld", &N, &M, &bounty, &increase, &damage);
  int i;
  int cnt = 0;
  for (i = 0; i < N; i++) {
    long long x;
    scanf("%lld%lld%lld", max_health + i, &x, regen + i);
    update e(0, x);
    U[i].push_back(e);
    if (max_health[i] <= damage && increase) {
      puts("-1");
      return 1;
    }
  }
  for (i = 0; i < M; i++) {
    long long a, b, c;
    scanf("%lld%lld%lld", &a, &b, &c);
    update e(a, c);
    U[b - 1].push_back(e);
  }
  return 0;
}
int main() {
  if (init()) return 0;
  int i, j;
  for (i = 0; i < N; i++) {
    sort(U[i].begin(), U[i].end());
    int s = U[i].size();
    for (j = 0; j < s; j++) {
      long long r = (j + 1 != s) ? (U[i][j + 1].time - 1) : INF;
      update n = U[i][j];
      if (n.health > damage) continue;
      long long up = INF;
      if (regen[i]) up = n.time + (damage - n.health) / regen[i];
      up = min(up, r);
      add(n.time, up);
    }
  }
  getAns();
  return 0;
}
