#include <bits/stdc++.h>
using namespace std;
int maxx[100000 + 1];
int start[100000 + 1];
int regen[100000 + 1];
vector<pair<int, int> > om[100000 + 1];
map<int, int> clipa;
struct upd {
  int first, second, z;
};
upd v[100000 + 1];
int moments[600000 + 1];
int smen[600000 + 1];
int N, M, K;
bool cmp(const upd A, const upd B) { return A.first < B.first; }
int main() {
  int i, temp, sec, now;
  int bnty, incr, dmg;
  long long res = 0;
  scanf("%d %d", &N, &M);
  scanf("%d %d %d", &bnty, &incr, &dmg);
  for (i = 1; i <= N; ++i) scanf("%d %d %d", &maxx[i], &start[i], &regen[i]);
  for (i = 1; i <= M; ++i)
    scanf("%d %d %d", &v[i].first, &v[i].second, &v[i].z);
  sort(v + 1, v + M + 1, cmp);
  for (i = 1; i <= M; ++i) om[v[i].second].push_back({v[i].first, v[i].z});
  for (i = 1; i <= N; ++i)
    if (!regen[i] && !om[i].size() && start[i] <= dmg && incr) {
      printf("-1\n");
      return 0;
    }
  for (i = 1; i <= N; ++i)
    if (!regen[i] && om[i].size())
      if (om[i][om[i].size() - 1].second <= dmg && incr) {
        printf("-1\n");
        return 0;
      }
  for (i = 1; i <= N; ++i) om[i].push_back({2 * 1000000000 + 2, dmg + 1});
  for (i = 1; i <= N; ++i)
    if (maxx[i] <= dmg && incr) {
      printf("-1\n");
      return 0;
    }
  for (i = 1; i <= N; ++i)
    if (regen[i]) {
      sec = 0;
      now = start[i];
      for (auto t : om[i]) {
        moments[++K] = sec;
        if (now <= dmg) {
          temp = min(sec + (dmg - now) / regen[i], t.first - 1);
          moments[++K] = temp;
        }
        now = t.second;
        sec = t.first;
      }
    }
  for (i = 1; i <= N; ++i)
    if (!regen[i]) {
      sec = 0;
      now = start[i];
      for (auto t : om[i]) {
        moments[++K] = sec;
        if (now <= dmg) {
          temp = t.first - 1;
          moments[++K] = temp;
        }
        now = t.second;
        sec = t.first;
      }
    }
  sort(moments + 1, moments + K + 1);
  for (i = 1; i <= K; ++i)
    if (!clipa[moments[i]]) clipa[moments[i]] = i;
  for (i = 1; i <= N; ++i)
    if (regen[i]) {
      sec = 0;
      now = start[i];
      for (auto t : om[i]) {
        if (now <= dmg) {
          temp = min(sec + (dmg - now) / regen[i], t.first - 1);
          smen[clipa[sec]] += 1;
          smen[clipa[temp] + 1] -= 1;
        }
        now = t.second;
        sec = t.first;
      }
    }
  for (i = 1; i <= N; ++i)
    if (!regen[i]) {
      sec = 0;
      now = start[i];
      for (auto t : om[i]) {
        moments[++K] = sec;
        if (now <= dmg) {
          temp = t.first - 1;
          smen[clipa[sec]] += 1;
          smen[clipa[temp] + 1] -= 1;
        }
        now = t.second;
        sec = t.first;
      }
    }
  for (i = 1; i <= K; ++i) smen[i] += smen[i - 1];
  for (i = 1; i <= K; ++i)
    res = max(res, 1LL * bnty * smen[i] + 1LL * smen[i] * moments[i] * incr);
  printf("%I64d\n", res);
  return 0;
}
