#include <bits/stdc++.h>
using namespace std;
int n, m;
long long bounty, damage, increase;
long long maxh[100010], sth[100010], reg[100010];
long long tim[100010], ene[100010], hea[100010];
vector<pair<long long, long long> > cng[100010], v;
int main() {
  scanf("%d%d%lld%lld%lld", &n, &m, &bounty, &increase, &damage);
  for (int i = 1; i <= n; i++) {
    scanf("%lld%lld%lld", maxh + i, sth + i, reg + i);
    if (maxh[i] <= damage) {
      if (increase > 0) {
        puts("-1");
        return 0;
      }
    }
  }
  for (int i = 1; i <= m; i++) {
    scanf("%lld%lld%lld", tim + i, ene + i, hea + i);
    cng[ene[i]].push_back({tim[i], hea[i]});
  }
  for (int i = 1; i <= n; i++) {
    cng[i].push_back({0, sth[i]});
    sort(cng[i].begin(), cng[i].end());
    for (int j = 0; j < ((int)cng[i].size()); j++) {
      if (cng[i][j].second > damage) continue;
      long long t;
      if (reg[i] == 0 || maxh[i] <= damage) {
        if (j == ((int)cng[i].size()) - 1) {
          if (increase > 0) {
            puts("-1");
            return 0;
          }
          t = -1;
        } else
          t = cng[i][j + 1].first - cng[i][j].first - 1;
      } else
        t = (damage - cng[i][j].second) / reg[i];
      if (j < ((int)cng[i].size()) - 1)
        t = min(t, cng[i][j + 1].first - cng[i][j].first - 1);
      v.push_back({cng[i][j].first, -1});
      if (t != -1) v.push_back({cng[i][j].first + t, 1});
    }
  }
  sort(v.begin(), v.end());
  long long res = 0, tot = 0;
  for (int i = 0; i < ((int)v.size()); i++) {
    res = max(res, tot * (bounty + v[i].first * increase));
    tot += -v[i].second;
    res = max(res, tot * (bounty + v[i].first * increase));
  }
  cout << res;
  return 0;
}
