#include <bits/stdc++.h>
using namespace std;
const long long N = 1e5 + 5;
long long mh[N], sh[N], r[N], n, m, bt, inc, dam, cnt = 0, flag = 0;
vector<pair<long long, long long>> V[N], P;
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n >> m >> bt >> inc >> dam;
  for (int i = 0; i < n; i++) {
    cin >> mh[i] >> sh[i] >> r[i];
    V[i].push_back(make_pair(0LL, sh[i]));
  }
  for (int i = 0; i < m; i++) {
    long long tm, en, h;
    cin >> tm >> en >> h;
    V[en - 1].push_back(make_pair(tm, h));
  }
  for (int i = 0; i < n; i++) sort(V[i].begin(), V[i].end());
  for (int i = 0; i < n; i++) {
    long long a, b, c;
    a = V[i][0].second;
    if (a <= dam) cnt++;
    for (int j = 1; j < V[i].size(); j++) {
      a = V[i][j - 1].second;
      long long tnow = V[i][j].first, tprev = V[i][j - 1].first;
      tnow--;
      b = min(mh[i], a + (tnow - tprev) * r[i]);
      if (a <= dam && b > dam) {
        long long t = tprev + (dam - a) / r[i];
        t++;
        P.push_back(make_pair(t, -1LL));
      }
      c = V[i][j].second;
      if (b <= dam && c > dam)
        P.push_back(make_pair(V[i][j].first, -1LL));
      else if (b > dam && c <= dam)
        P.push_back(make_pair(tnow + 1, 1LL));
    }
    long long hf = V[i].back().second, tf = V[i].back().first;
    if (hf <= dam) {
      if (r[i] > 0 && mh[i] > dam) {
        long long t = tf + (dam - hf) / r[i];
        t++;
        P.push_back(make_pair(t, -1LL));
      } else
        flag = 1;
    }
  }
  sort(P.begin(), P.end());
  if (flag && inc != 0) {
    cout << -1;
    return 0;
  }
  long long mx = bt * cnt, fmx = cnt;
  long long ix = 0;
  while (ix < P.size()) {
    long long t = P[ix].first;
    mx = max(mx, bt * cnt + (t - 1) * inc * cnt);
    while (P[ix].first == t) {
      cnt += P[ix].second;
      ix++;
    }
    mx = max(mx, bt * cnt + t * inc * cnt);
    fmx = max(fmx, cnt);
  }
  cout << mx << endl;
}
