#include <bits/stdc++.h>
using namespace std;
const int N = 101010;
const long long inf = 1e18;
int n, m;
int bon, inc, dam;
int ma[N], reg[N], cnt[N];
vector<pair<int, int> > ini[N];
vector<pair<long long, pair<int, int> > > scan;
void solve() {
  for (int i = (1); i < (n + 1); i++) sort(ini[i].begin(), ini[i].end());
  if (inc)
    for (int i = (1); i < (n + 1); i++)
      if (ma[i] <= dam ||
          (ini[i][(int)ini[i].size() - 1].second <= dam && reg[i] == 0)) {
        puts("-1");
        return;
      }
  for (int i = (1); i < (n + 1); i++) {
    for (int j = (0); j < ((int)ini[i].size()); j++) {
      int t = ini[i][j].first;
      int s = ini[i][j].second;
      if (s <= dam) {
        scan.push_back(make_pair(t, make_pair(-1, i)));
        long long t0;
        if (ma[i] <= dam || reg[i] == 0) {
          t0 = inf;
        } else {
          t0 = 1ll * (dam - s) / reg[i] + t;
        }
        if (j + 1 < (int)ini[i].size())
          t0 = min(t0, (long long)ini[i][j + 1].first - 1);
        scan.push_back(make_pair(t0, make_pair(1, i)));
      } else {
      }
    }
  }
  long long ans = 0;
  int now = 0;
  sort(scan.begin(), scan.end());
  for (int i = (0); i < ((int)scan.size()); i++) {
    long long t = scan[i].first;
    int x = -scan[i].second.first;
    int y = scan[i].second.second;
    if (x == 1) {
      if (cnt[y] == 0) ++now;
      ++cnt[y];
      long long res = (bon + inc * t) * now;
      ans = max(ans, res);
    } else {
      long long res = (bon + inc * t) * now;
      ans = max(ans, res);
      if (cnt[y]) {
        --cnt[y];
        if (cnt[y] == 0) {
          --now;
        }
      }
    }
  }
  printf("%lld\n", ans);
}
int main() {
  while (~scanf("%d%d%d%d%d", &n, &m, &bon, &inc, &dam)) {
    for (int i = (0); i < (n + 1); i++) ini[i].clear();
    memset(cnt, 0, sizeof(cnt));
    scan.clear();
    for (int i = (1); i < (n + 1); i++) {
      int x, y, z;
      scanf("%d%d%d", &x, &y, &z);
      ma[i] = x;
      ini[i].push_back(make_pair(0, y));
      reg[i] = z;
    }
    for (int i = (1); i < (m + 1); i++) {
      int x, y, z;
      scanf("%d%d%d", &x, &y, &z);
      ini[y].push_back(make_pair(x, z));
    }
    solve();
  }
  return 0;
}
