#include <bits/stdc++.h>
using namespace std;
const long long inf = 9.2e18;
const int maxn = 1e5 + 70;
const int INF = 2.1e9;
const int maxm = 2e6 + 70;
const int MOD = 1e9 + 7;
const double eps = 1e-7;
const double PI = acos(-1.0);
int n, m, k;
bool inq[maxn];
int otime[maxn], reg[maxn], bound[maxn];
long long ans;
int cnt, bounty, increase, damage;
struct node;
priority_queue<node> Q;
struct node {
  int d, t, v, h;
  node(int d, int t, int v, int h) : d(d), t(t), v(v), h(h) {}
  bool operator<(const node& rhs) const {
    return t > rhs.t || (t == rhs.t && d > rhs.d);
  }
  void go() {
    if (d == 0) {
      if (inq[v] && otime[v] == t) {
        inq[v] = 0;
        cnt--;
      }
    } else if (d == 1) {
      if (h > damage) {
        if (inq[v]) {
          inq[v] = 0;
          cnt--;
        }
      } else {
        if (!inq[v]) {
          inq[v] = 1;
          cnt++;
        }
        if (reg[v] > 0) {
          otime[v] = t + (damage + 1 - h) / reg[v];
          if ((damage + 1 - h) % reg[v]) otime[v]++;
          Q.push(node(0, otime[v], v, -1));
          Q.push(node(2, otime[v] - 1, v, -1));
        } else {
          otime[v] = INF;
          Q.push(node(2, INF, v, -1));
        }
      }
    } else if (d == 2) {
      if (t == INF && increase > 0)
        ans = -1;
      else
        ans = max(ans, (long long)cnt * (bounty + (long long)t * increase));
    }
  }
};
int main() {
  while (cin >> n >> m) {
    int mini = INF;
    cin >> bounty >> increase >> damage;
    int flag = 0;
    ans = -1;
    cnt = 0;
    memset(inq, 0, sizeof(inq));
    while (!Q.empty()) Q.pop();
    for (int i = 1; i <= n; i++) {
      int h;
      scanf("%d%d%d", &bound[i], &h, &reg[i]);
      if (increase > 0 && bound[i] <= damage) flag = 1;
      if (h <= damage) {
        inq[i] = 1;
        cnt++;
        if (reg[i] > 0) {
          otime[i] = (damage + 1 - h) / reg[i];
          if ((damage + 1 - h) % reg[i]) otime[i]++;
          Q.push(node(0, otime[i], i, -1));
          Q.push(node(2, otime[i] - 1, i, -1));
        } else {
          otime[i] = INF;
          Q.push(node(2, INF, i, -1));
        }
        mini = min(mini, otime[i]);
      }
    }
    for (int i = 1; i <= m; i++) {
      int t, v, h;
      scanf("%d%d%d", &t, &v, &h);
      Q.push(node(1, t, v, h));
      Q.push(node(2, t - 1, -1, -1));
    }
    Q.push(node(2, 0, -1, -1));
    if (!flag) {
      while (!Q.empty()) {
        node x = Q.top();
        Q.pop();
        x.go();
      }
    }
    cout << ans << endl;
  }
  return 0;
}
