#include <bits/stdc++.h>
using namespace std;
const int oo = 0x3f3f3f3f;
const long long ooo = 9223372036854775807ll;
const int _cnt = 1000 * 1000 + 7;
const int _p = 1000 * 1000 * 1000 + 7;
const int N = 500005;
const double PI = acos(-1.0);
const double eps = 1e-9;
int o(int x) { return x % _p; }
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
void file_put() {
  freopen("filename.in", "r", stdin);
  freopen("filename.out", "w", stdout);
}
struct etype {
  long long t, h;
} e, tt;
inline bool operator<(const etype &e1, const etype &e2) { return e1.t < e2.t; }
inline bool cmp(long long x, long long y) { return abs(x) < abs(y); }
int n, m, B, I, D, h[N], s[N], r[N], x, ss = 0;
vector<etype> V[N];
long long ans = 0, p[N];
int G(int k, const etype &e, long long t) {
  if (r[k] > 0 && t - e.t >= h[k] || r[k] && (h[k] - 1) / r[k] + 1 <= t - e.t)
    return h[k];
  return ((e.h + (long long)(t - e.t) * r[k]) < (h[k])
              ? (e.h + (long long)(t - e.t) * r[k])
              : (h[k]));
}
void bat(int k, const etype &e, const etype &tt) {
  if (tt.h == e.h) return;
  long long t = r[k] ? e.t + (D - e.h) / r[k] : oo;
  if (e.h > D && tt.h <= D) p[++p[0]] = tt.t;
  if (e.h <= D && tt.h > D)
    t++, t = ((t) < (tt.t) ? (t) : (tt.t)), p[++p[0]] = -t;
}
int main() {
  scanf("%d%d%d%d%d", &n, &m, &B, &I, &D);
  for (int i = (1); i <= (n); ++i) scanf("%d%d%d", &h[i], &s[i], &r[i]);
  for (int i = (1); i <= (n); ++i)
    if (h[i] <= D && I && r[i]) return 0 * printf("-1\n");
  for (int i = (1); i <= (m); ++i)
    scanf("%d%d%d", &e.t, &x, &e.h), V[x].push_back(e);
  for (int i = (1); i <= (n); ++i) {
    sort((V[i]).begin(), (V[i]).end());
    e = etype{0, s[i]};
    for (__typeof((V[i]).begin()) it = (V[i]).begin(); it != (V[i]).end(); it++)
      tt = etype{it->t - 1, G(i, e, it->t - 1)}, bat(i, e, tt), bat(i, tt, *it),
      e = *it;
    if (e.h <= D && r[i] == 0 && I) return 0 * printf("-1\n");
    if (e.h <= D && r[i] > 0 && h[i] > D) {
      long long t = e.t + (D - e.h) / r[i] + 1;
      bat(i, e, etype{t, G(i, e, t)});
    }
  }
  sort(p + 1, p + p[0] + 1, cmp);
  for (int i = (1); i <= (n); ++i) ss += (s[i] <= D);
  ans = (long long)ss * B;
  for (int i = (1); i <= (p[0]); ++i) {
    if (i == 1 || i > 1 && abs(p[i]) > abs(p[i - 1]))
      ans = ((ans) > ((long long)ss * (B + (abs(p[i]) - 1) * I))
                 ? (ans)
                 : ((long long)ss * (B + (abs(p[i]) - 1) * I)));
    ss += (p[i] > 0) - (p[i] < 0);
  }
  printf("%I64d\n", ans);
  return 0;
}
