#include <bits/stdc++.h>
using namespace std;
struct Node {
  int t, h;
};
const int N = 1e5 + 10;
const int INF = 2e9;
vector<Node> sav[N];
vector<pair<int, int> > rec;
vector<int> dct;
map<int, int> _hash;
int maxh[N], reg[N], cnt[N << 3];
bool cmp(const Node& p, const Node& q) { return p.t < q.t; }
int main() {
  int n, m, bty, inc, dmg, t, id, h, sz, sz2;
  long long ans, temp;
  scanf("%d %d", &n, &m);
  scanf("%d %d %d", &bty, &inc, &dmg);
  for (int i = 1; i <= n; i++) {
    scanf("%d %d %d", &maxh[i], &h, &reg[i]);
    sav[i].push_back({0, h});
  }
  for (int i = 1; i <= m; i++) {
    scanf("%d %d %d", &t, &id, &h);
    sav[id].push_back({t, h});
  }
  for (int i = 1; i <= n; i++) {
    sort(sav[i].begin(), sav[i].end(), cmp);
    sz = (int)sav[i].size();
    if (inc > 0 &&
        ((maxh[i] <= dmg) || (reg[i] == 0 && sav[i][sz - 1].h <= dmg))) {
      printf("-1\n");
      return 0;
    }
    sav[i].push_back({INF, 0});
    for (int j = 0; j < sz; j++) {
      if (sav[i][j].h > dmg) continue;
      if (reg[i] == 0 || maxh[i] <= dmg) {
        rec.emplace_back(sav[i][j].t, sav[i][j + 1].t);
        dct.push_back(sav[i][j].t);
        dct.push_back(sav[i][j + 1].t - 1);
        dct.push_back(sav[i][j + 1].t);
      } else {
        t = (dmg - sav[i][j].h) / reg[i] + sav[i][j].t + 1;
        t = min(t, sav[i][j + 1].t);
        rec.emplace_back(sav[i][j].t, t);
        dct.push_back(sav[i][j].t);
        dct.push_back(t - 1);
        dct.push_back(t);
      }
    }
  }
  sort(dct.begin(), dct.end());
  sz = unique(dct.begin(), dct.end()) - dct.begin();
  for (int i = 0; i < sz; i++) _hash.insert(make_pair(dct[i], i + 1));
  sz2 = (int)rec.size();
  memset(cnt, 0, sizeof(cnt));
  for (int i = 0; i < sz2; i++) {
    cnt[_hash[rec[i].first]]++;
    cnt[_hash[rec[i].second]]--;
  }
  for (int i = 2; i <= sz; i++) cnt[i] += cnt[i - 1];
  ans = 0;
  for (int i = 1; i <= sz; i++) {
    temp = 1LL * dct[i - 1] * inc + bty;
    ans = max(ans, temp * cnt[i]);
  }
  printf("%I64d\n", ans);
  return 0;
}
