#include <bits/stdc++.h>
using namespace std;
const long long MAXN = 1e5 + 5, INF = 0x3f3f3f3f3f3f3f3f;
struct iii {
  long long a, b, c;
  bool operator<(iii o) const { return tie(a, b, c) < tie(o.a, o.b, o.c); }
};
struct ii {
  long long a, b;
  bool operator<(ii o) const { return tie(a, b) < tie(o.a, o.b); }
};
long long N, M, regen[MAXN], maks[MAXN];
vector<ii> ev, player[MAXN];
iii koin;
long long hitung(long long hp, long long prog) { return (koin.c - hp) / prog; }
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> N >> M;
  cin >> koin.a >> koin.b >> koin.c;
  for (int i = 1; i <= N; i++) {
    long long x;
    cin >> maks[i] >> x >> regen[i];
    player[i].push_back({0, x});
  }
  for (int i = 1; i <= M; i++) {
    long long x, y, z;
    cin >> x >> y >> z;
    player[y].push_back({x, z});
  }
  for (int i = 1; i <= N; i++) {
    player[i].push_back({INF, 1});
    sort(player[i].begin(), player[i].end());
    for (int j = 0, mj = player[i].size(); j < mj - 1; j++) {
      if (player[i][j].b > koin.c) continue;
      if (regen[i] == 0 || maks[i] <= koin.c) {
        ev.push_back({player[i][j].a, 1});
        ev.push_back({player[i][j + 1].a, -1});
      } else {
        long long akhir = player[i][j].a + hitung(player[i][j].b, regen[i]) + 1;
        ev.push_back({player[i][j].a, 1});
        ev.push_back({min(akhir, player[i][j + 1].a), -1});
      }
    }
  }
  sort(ev.begin(), ev.end());
  long long cur = 0, ans = 0;
  if (!ev.empty() && ev.back().a == INF) {
    if (koin.b != 0) return cout << "-1\n", 0;
  } else
    ev.push_back({INF, 1});
  for (int i = 0; i < (int)ev.size() - 1; i++) {
    cur += ev[i].b;
    if (ev[i + 1].a == ev[i].a) continue;
    ans = max(ans, cur * (koin.a + koin.b * (ev[i + 1].a - 1)));
  }
  cout << ans << "\n";
  return 0;
}
