#include <bits/stdc++.h>
using namespace std;
int const maxn = 1e5 + 10;
struct bkn {
  long long t, e, h, v, m, r, s;
  bool friend operator<(bkn a, bkn b) { return a.t < b.t; }
} ud[maxn], d[10 * maxn], a[maxn];
long long l[maxn], p[maxn];
int vis[maxn];
int tot1 = 0;
int main() {
  std::ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  long long bo, in, da;
  cin >> bo >> in >> da;
  for (int i = 1; i <= n; i++) {
    cin >> a[i].m >> a[i].s >> a[i].r;
  }
  for (int i = 1; i <= m; i++) {
    cin >> ud[i].t >> ud[i].e >> ud[i].h;
  }
  sort(ud + 1, ud + 1 + m);
  long long q = 0;
  for (int i = 1; i <= n; i++) {
    if (a[i].s <= da) q++, vis[i] = 1;
    if (a[i].r == 0 || a[i].m < da)
      p[i] = -1;
    else
      p[i] = (da - a[i].s) / a[i].r;
  }
  for (int i = 1; i <= m; i++) {
    int x = ud[i].e;
    if (p[x] >= l[x] && p[x] <= ud[i].t - 1 && vis[x]) {
      d[++tot1].t = p[x];
      d[tot1].v = -1;
      vis[x] = 0;
    }
    if (ud[i].h > da && vis[x]) {
      d[++tot1].t = ud[i].t - 1;
      d[tot1].v = -1;
      vis[x] = 0;
    } else if (!vis[x] && ud[i].h <= da) {
      d[++tot1].t = ud[i].t - 1;
      d[tot1].v = 1;
      vis[x] = 1;
    }
    a[x].s = ud[i].h - a[x].r * ud[i].t;
    if (a[x].r == 0 || a[x].m < da)
      p[x] = -1;
    else
      p[x] = (da - a[x].s) / a[x].r;
    l[x] = ud[i].t;
  }
  for (int i = 1; i <= n; i++) {
    int x = i;
    if (vis[x]) {
      d[++tot1].t = p[x];
      d[tot1].v = -1;
      if (a[x].r == 0 || a[x].m <= da) d[tot1].v = 0;
    }
  }
  sort(d + 1, d + 1 + tot1);
  int tt = 0;
  int i = 1;
  long long ans = 0;
  while (i <= tot1) {
    ans = max(ans, q * (bo + in * d[i].t));
    q += d[i++].v;
    while (i <= tot1 && d[i].t == d[i - 1].t) q += d[i++].v;
  }
  if (q && in)
    cout << -1 << endl;
  else
    cout << ans << endl;
}
