#include <bits/stdc++.h>
using namespace std;
const int N = 100002;
int n, m, bounty, increase, damage, mnMaxHealth = 1000000000;
int mxHealth[N], stHealth[N], regen[N];
vector<vector<pair<int, int>>> updates(N);
int main() {
  scanf("%d%d", &n, &m);
  scanf("%d%d%d", &bounty, &increase, &damage);
  for (int i = 1; i <= n; ++i) {
    scanf("%d%d%d", &mxHealth[i], &stHealth[i], &regen[i]);
    mnMaxHealth = min(mnMaxHealth, mxHealth[i]);
    if (increase and !regen[i] and stHealth[i] <= damage) return cout << -1, 0;
  }
  for (int i = 1; i <= m; ++i) {
    int t, a, b;
    scanf("%d%d%d", &t, &a, &b);
    updates[a].push_back(pair<int, int>(t, b));
  }
  if (increase and mnMaxHealth <= damage) return cout << -1, 0;
  for (int i = 1; i <= n; ++i) sort(updates[i].begin(), updates[i].end());
  vector<pair<int, int>> ranges;
  for (int i = 1; i <= n; ++i) {
    int currT = 0;
    int currH = stHealth[i];
    if (!((int)(updates[i]).size()) and currH <= damage) {
      int l = currT;
      int r =
          currT + (regen[i] ? (damage - currH) / regen[i] : 1000000000 - currT);
      ranges.push_back({l, 0});
      ranges.push_back({r, 1});
    }
    for (pair<int, int> p : updates[i]) {
      int newTime = p.first;
      int newH = p.second;
      int healthB4Update = min(1ll * mxHealth[i],
                               currH + 1ll * regen[i] * (newTime - 1 - currT));
      if (healthB4Update > damage and currH <= damage) {
        int l = currT;
        int r = regen[i] ? currT + (damage - currH) / regen[i] : newTime - 1;
        ranges.push_back({l, 0});
        ranges.push_back({r, 1});
      }
      if (healthB4Update <= damage) {
        ranges.push_back({currT, 0});
        ranges.push_back({newTime - 1, 1});
      }
      currT = newTime;
      currH = newH;
      if (p == updates[i].back() and currH <= damage) {
        int l = currT;
        int r = currT +
                (regen[i] ? (damage - currH) / regen[i] : 1000000000 - currT);
        ranges.push_back({l, 0});
        ranges.push_back({r, 1});
      }
    }
  }
  sort(ranges.begin(), ranges.end());
  long long ans = 0, curr = 0;
  for (pair<int, int> p : ranges) {
    curr += p.second == 0;
    ans = max(ans, curr * (bounty + 1ll * p.first * increase));
    curr -= p.second == 1;
  }
  cout << ans;
}
