#include <bits/stdc++.h>
using namespace std;
const long long N = 100005;
long long n, m, x, y, z, cnt, ans;
long long a[N], b[N];
vector<pair<long long, long long> > st[N], ch;
void proc(long long M, long long R, long long H, long long S, long long E) {
  if (H > z) return;
  ch.push_back({S, 1});
  if (R == 0 || M <= z) {
    if (~E) ch.push_back({E, -1});
  } else {
    long long req = (z + 1 - H + R - 1) / R;
    if (~E)
      ch.push_back({min(E, S + req), -1});
    else
      ch.push_back({S + req, -1});
  }
}
int main() {
  scanf("%lld%lld%lld%lld%lld", &n, &m, &x, &y, &z);
  for (long long i = 1; i <= n; i++) {
    long long T;
    scanf("%lld%lld%lld", &a[i], &T, &b[i]);
    st[i].push_back({0, T});
  }
  for (long long i = 1; i <= m; i++) {
    long long A, B, C;
    scanf("%lld%lld%lld", &A, &B, &C);
    st[B].push_back({A, C});
  }
  for (long long i = 1; i <= n; i++) {
    sort(st[i].begin(), st[i].end());
    for (long long j = 0; j < st[i].size(); j++) {
      proc(a[i], b[i], st[i][j].second, st[i][j].first,
           (j + 1 == st[i].size() ? -1 : st[i][j + 1].first));
    }
  }
  sort(ch.begin(), ch.end());
  for (long long i = 0; i < ch.size(); i++) {
    cnt += ch[i].second;
    if (i + 1 != ch.size() && ch[i].first != ch[i + 1].first) {
      ans = max(ans, cnt * (x + (ch[i + 1].first - 1) * y));
    }
  }
  if (cnt > 0) {
    if (y > 0) {
      puts("-1");
      return 0;
    } else
      ans = max(ans, cnt * x);
  }
  printf("%lld\n", ans);
}
