#include <bits/stdc++.h>
using namespace std;
const long long W = 1000000000000;
int N, M, i, j;
long long B, C, D, H[100005], R[100005], X, Y, Z;
vector<pair<long long, long long> > V[100005], T;
void hit(long long L, long long R, long long X, long long Y) {
  if (X > D) {
    return;
  }
  T.push_back(pair<long long, long long>(L, 1));
  if (Y == 0) {
    if (C > 0 && R == W - 1) {
      cout << -1 << '\n';
      exit(0);
    }
    T.push_back(pair<long long, long long>(R + 1, -1));
    return;
  }
  T.push_back(pair<long long, long long>(min(R, L + (D - X) / Y) + 1, -1));
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> N >> M >> B >> C >> D;
  for (i = 1; i <= N; i++) {
    cin >> H[i] >> X >> R[i];
    V[i].push_back(pair<long long, long long>(0, X));
    if (C > 0 && H[i] <= D) {
      cout << -1 << '\n';
      return 0;
    }
  }
  for (i = 1; i <= M; i++) {
    cin >> X >> Y >> Z;
    V[Y].push_back(pair<long long, long long>(X, Z));
  }
  for (i = 1; i <= N; i++) {
    sort(V[i].begin(), V[i].end());
    V[i].push_back(pair<long long, long long>(W, 0));
    for (j = V[i].size() - 2; j >= 0; j--) {
      hit(V[i][j].first, V[i][j + 1].first - 1, V[i][j].second, R[i]);
    }
  }
  sort(T.begin(), T.end());
  X = 0;
  Y = 0;
  for (i = 0; i + 1 < T.size(); i++) {
    X += T[i].second;
    if (T[i].first != T[i + 1].first) {
      Y = max(Y, X * (B + C * (T[i + 1].first - 1)));
    }
  }
  cout << Y << '\n';
}
