#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define F first
#define S second
typedef pair<ll,ll> ii;
typedef pair<ll,ii> iii;
bool isAll;
ll n,m,bounty,increase,dmg;
iii mons[200000],upd[200000];
ll calc(ll t){
ll mons_cur[200000];
for(int i = 1;i<=n;i++){
mons_cur[i] = min(mons[i].F,mons[i].S.F + t*mons[i].S.S);
}
for(int i = 1;i<=m;i++){
ll time = upd[i].F;
ll pos = upd[i].S.F;
ll health = upd[i].S.S;
if(time <= t){
mons_cur[pos] = min(mons[pos].F,health + mons[pos].S.S*(t-time));
}
}
ll sl = 0;
for(int i = 1;i<=n;i++)if(mons_cur[i] <= dmg)sl++;
if(sl == n) isAll = true;
return sl * (bounty + t*increase);
}
int main()
{
cin >> n >> m;
cin >> bounty >> increase >> dmg;
bool bo = true;
for(int i = 1;i<=n;i++){
ll x,y,z; cin >> x >> y >> z;
mons[i] = iii(x,ii(y,z));
//if(dmg < x) bo = false;
}
for(int i = 1;i<=m;i++){
ll x,y,z; cin >> x >> y >> z;
upd[i] = iii(x,ii(y,z));
}
ll l = 1,r = round(1e15),cnt = 0;
while(cnt <= 300){
isAll = false;
ll m1 = l + (r-l) / 3;
ll m2 = r - (r-l) / 3;
ll r1 = calc(m1),r2 = calc(m2);
if(r1 < r2) l = m1; else r = m2;
cnt++;
if(!isAll) bo = false;
}
if(bo) cout << -1; else cout << calc((l+r)/2);
//cout << calc(50);
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+Cgp1c2luZyBuYW1lc3BhY2Ugc3RkOwojZGVmaW5lIGxsIGxvbmcgbG9uZwojZGVmaW5lIEYgZmlyc3QKI2RlZmluZSBTIHNlY29uZAp0eXBlZGVmIHBhaXI8bGwsbGw+IGlpOwp0eXBlZGVmIHBhaXI8bGwsaWk+IGlpaTsKYm9vbCBpc0FsbDsKbGwgbixtLGJvdW50eSxpbmNyZWFzZSxkbWc7CmlpaSBtb25zWzIwMDAwMF0sdXBkWzIwMDAwMF07CmxsIGNhbGMobGwgdCl7CiAgICBsbCBtb25zX2N1clsyMDAwMDBdOwogICAgZm9yKGludCBpID0gMTtpPD1uO2krKyl7CiAgICAgICAgbW9uc19jdXJbaV0gPSBtaW4obW9uc1tpXS5GLG1vbnNbaV0uUy5GICsgdCptb25zW2ldLlMuUyk7CiAgICB9CiAgICBmb3IoaW50IGkgPSAxO2k8PW07aSsrKXsKICAgICAgICBsbCB0aW1lID0gdXBkW2ldLkY7CiAgICAgICAgbGwgcG9zID0gdXBkW2ldLlMuRjsKICAgICAgICBsbCBoZWFsdGggPSB1cGRbaV0uUy5TOwogICAgICAgIGlmKHRpbWUgPD0gdCl7CiAgICAgICAgICAgIG1vbnNfY3VyW3Bvc10gPSBtaW4obW9uc1twb3NdLkYsaGVhbHRoICsgbW9uc1twb3NdLlMuUyoodC10aW1lKSk7CiAgICAgICAgfQogICAgfQogICAgbGwgc2wgPSAwOwogICAgZm9yKGludCBpID0gMTtpPD1uO2krKylpZihtb25zX2N1cltpXSA8PSBkbWcpc2wrKzsKICAgIGlmKHNsID09IG4pIGlzQWxsID0gdHJ1ZTsKICAgIHJldHVybiBzbCAqIChib3VudHkgKyB0KmluY3JlYXNlKTsKfQppbnQgbWFpbigpCnsKICAgIGNpbiA+PiBuID4+IG07CiAgICBjaW4gPj4gYm91bnR5ID4+IGluY3JlYXNlID4+IGRtZzsKICAgIGJvb2wgYm8gPSB0cnVlOwogICAgZm9yKGludCBpID0gMTtpPD1uO2krKyl7CiAgICAgICAgbGwgeCx5LHo7IGNpbiA+PiB4ID4+IHkgPj4gejsKICAgICAgICBtb25zW2ldID0gaWlpKHgsaWkoeSx6KSk7CiAgICAgICAgLy9pZihkbWcgPCB4KSBibyA9IGZhbHNlOwogICAgfQogICAgZm9yKGludCBpID0gMTtpPD1tO2krKyl7CiAgICAgICAgbGwgeCx5LHo7IGNpbiA+PiB4ID4+IHkgPj4gejsKICAgICAgICB1cGRbaV0gPSBpaWkoeCxpaSh5LHopKTsKICAgIH0KICAgIGxsIGwgPSAxLHIgPSByb3VuZCgxZTE1KSxjbnQgPSAwOwogICAgd2hpbGUoY250IDw9IDMwMCl7CiAgICAgICAgaXNBbGwgPSBmYWxzZTsKICAgICAgICBsbCBtMSA9IGwgKyAoci1sKSAvIDM7CiAgICAgICAgbGwgbTIgPSByIC0gKHItbCkgLyAzOwogICAgICAgIGxsIHIxID0gY2FsYyhtMSkscjIgPSBjYWxjKG0yKTsKICAgICAgICBpZihyMSA8IHIyKSBsID0gbTE7IGVsc2UgciA9IG0yOwogICAgICAgIGNudCsrOwogICAgICAgIGlmKCFpc0FsbCkgYm8gPSBmYWxzZTsKICAgIH0KICAgIGlmKGJvKSBjb3V0IDw8IC0xOyBlbHNlIGNvdXQgPDwgY2FsYygobCtyKS8yKTsKICAgIC8vY291dCA8PCBjYWxjKDUwKTsKICAgIHJldHVybiAwOwp9