#include <bits/stdc++.h>
using namespace std;
void func(void) {
  freopen("input.c", "r", stdin);
  freopen("output.c", "w", stdout);
}
const int N = 1e5 + 100;
struct c {
  long long maxH, start, reg;
};
vector<pair<long long, long long> > a[N];
vector<c> v;
long long bounty, increase, damage;
vector<pair<pair<long long, long long>, long long> > v1;
set<int> s;
int cc[N];
int main() {
  long long n, q, i, j = 0, temp, t, k, ans = 0, sum = 0, x, y, z, cnt = 0, m,
                     fg = 0, mx = 0, mx1 = 0, mn = 8000000000000000000,
                     mn1 = 8000000000000000000;
  scanf("%lld %lld", &n, &m);
  scanf("%lld %lld %lld", &bounty, &increase, &damage);
  for (int i = 0; i < n; i++) {
    c k;
    scanf("%lld %lld %lld", &k.maxH, &k.start, &k.reg);
    v.push_back(k);
  }
  for (int i = 0; i < m; i++) {
    long long timeJ, health, enemy;
    scanf("%lld %lld %lld", &timeJ, &enemy, &health);
    a[enemy].push_back({timeJ, health});
  }
  for (int i = 1; i <= n; i++) {
    sort(a[i].begin(), a[i].end());
  }
  for (int i = 0; i < n; i++) {
    long long maxH = v[i].maxH, start = v[i].start, reg = v[i].reg;
    long long now = 0, newP = start;
    for (int j = 0; j < a[i + 1].size(); j++) {
      long long tt = a[i + 1][j].first;
      long long in = a[i + 1][j].second;
      long long rem = tt - now - 1;
      temp = newP + rem * reg;
      temp = min(temp, maxH);
      if (newP > damage) {
        now = tt;
      } else if (temp > damage and reg != 0) {
        temp = damage - newP;
        temp /= reg;
        v1.push_back({{now, -1}, i + 1});
        newP += rem * reg;
        newP = min(newP, maxH);
        now += temp;
        v1.push_back({{now, 0}, i + 1});
        now = tt - 1;
      } else {
        v1.push_back({{now, -1}, i + 1});
        newP = temp;
        now = tt - 1;
        v1.push_back({{now, 0}, i + 1});
      }
      newP = in;
      newP = min(newP, maxH);
      if (newP <= damage) {
        now = tt;
        v1.push_back({{now, -1}, i + 1});
        v1.push_back({{now, 0}, i + 1});
      }
    }
    if (newP <= damage) {
      if (maxH <= damage and increase != 0) {
        printf("-1\n");
        return 0;
      } else if (maxH <= damage) {
        v1.push_back({{now, -1}, i + 1});
      } else {
        v1.push_back({{now, -1}, i + 1});
        if (reg != 0) {
          now += (damage - newP) / reg;
          v1.push_back({{now, 0}, i + 1});
        } else if (reg == 0 and increase != 0) {
          printf("-1\n");
          return 0;
        }
      }
    }
  }
  sort(v1.begin(), v1.end());
  unsigned long long xx = 0, cur = 0, now = 0;
  for (int i = 0; i < v1.size(); i++) {
    now = v1[i].first.first;
    x = v1[i].second;
    if (v1[i].first.second == -1) cc[x]++;
    if (cc[x]) s.insert(x);
    unsigned long long tt = now * increase;
    unsigned long long temp = (unsigned long long)s.size() * (bounty + tt);
    xx = max(xx, temp);
    if (v1[i].first.second != -1) cc[x]--;
    if (cc[x] == 0) s.erase(x);
  }
  printf("%llu\n", xx);
}
