#include <bits/stdc++.h>
using namespace std;
const long double E = 2.71828182845904523536;
const long double pi = acos(-1);
const double eps = 1e-9;
const long long mod = 1e9 + 7;
const long long inf = 1LL << 30;
const int N = 100100;
map<long long, pair<int, int> > ren;
vector<pair<int, int> > v[N];
struct p {
  int mx;
  int st;
  int d;
};
p a[N];
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  int b, d, MX;
  scanf("%d%d%d", &b, &d, &MX);
  bool _1 = 0;
  for (int i = 1; i <= n; i++) {
    scanf("%d%d%d", &a[i].mx, &a[i].st, &a[i].d);
    if (a[i].mx <= MX) _1 = 1;
    if (a[i].st <= MX) v[i].push_back({0, a[i].st});
  }
  for (int i = 0; i < m; i++) {
    int tid, id, sid;
    scanf("%d%d%d", &tid, &id, &sid);
    v[id].push_back({tid, sid});
  }
  if (_1 && d) {
    printf("-1");
    return 0;
  }
  for (int i = 1; i <= n; i++) {
    sort(v[i].begin(), v[i].end());
    if (!v[i].size()) continue;
    if (a[i].d == 0) {
      if (!d) {
        bool f = 0;
        for (int j = 0; j < v[i].size(); j++) {
          if (v[i][j].second > MX) {
            if (f) {
              ren[v[i][j].first].second--;
              f = 0;
            }
          } else if (!f) {
            ren[v[i][j].first].first++;
            f = 1;
          }
        }
      } else if ((v[i].back()).second <= MX)
        _1 = 1;
      continue;
    }
    for (int j = 0; j < v[i].size(); j++) {
      if (v[i][j].second > MX) continue;
      ren[v[i][j].first].first++;
      long long x = v[i][j].second, d = a[i].d;
      long long lo = 0, hi = inf;
      while (hi > lo) {
        long long mid = (lo + hi + 1) >> 1;
        if (x + d * mid <= MX)
          lo = mid;
        else
          hi = mid - 1;
      }
      if (j == v[i].size() - 1)
        ren[v[i][j].first + lo].second--;
      else
        ren[min(v[i][j].first + lo, (long long)v[i][j + 1].first - 1)].second--;
    }
  }
  if (_1 && d) {
    printf("-1");
    return 0;
  }
  long long ans = 0;
  long long cnt = 0;
  for (auto x : ren) {
    cnt += x.second.first;
    ans = max(ans, cnt * (b * 1LL + (x.first * d)));
    cnt += x.second.second;
  }
  printf("%lld", ans);
  return 0;
}
