#include <bits/stdc++.h>
using namespace std;
using f64 = double;
using i64 = long long;
using f80 = long double;
using pii = pair<int, int>;
const i64 INF = 1e18;
const int N = 1e5 + 5;
struct Update {
  i64 time, health;
};
struct Man {
  i64 maxh, regen;
  vector<Update> updates;
};
Man v[N];
multiset<pair<i64, int>> s;
i64 bounty, rate, damage;
int n, m;
static i64 up(f64 first) { return i64(first + 1e-5) + 1; }
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  i64 dead, bound, ant, sum;
  cin >> n >> m;
  cin >> bounty >> rate >> damage;
  for (int t, i = 1; i <= n; ++i) {
    cin >> v[i].maxh >> t >> v[i].regen;
    v[i].updates.push_back({0, t});
  }
  for (int t, e, h, i = 1; i <= m; ++i) {
    cin >> t >> e >> h;
    v[e].updates.push_back({t, h});
  }
  dead = 0;
  for (int i = 1; i <= n; ++i) {
    if (v[i].maxh <= damage && rate > 0) {
      cout << "-1\n";
      return 0;
    }
    sort(begin(v[i].updates), end(v[i].updates),
         [&](Update a, Update b) { return a.time < b.time; });
    if (v[i].regen == 0) {
      if (v[i].updates.back().health <= damage && rate > 0) {
        cout << "-1\n";
        return 0;
      }
      for (int j = 0; j < v[i].updates.size(); ++j)
        if (v[i].updates[j].health <= damage) {
          s.emplace(v[i].updates[j].time, 1);
          if (j != v[i].updates.size() - 1)
            s.emplace(v[i].updates[j + 1].time, -1);
          else
            s.emplace(INF, -1);
        }
      continue;
    }
    for (int j = 0; j < v[i].updates.size(); ++j)
      if (v[i].updates[j].health <= damage) {
        s.emplace(v[i].updates[j].time + 1, 0);
        s.emplace(v[i].updates[j].time, 1);
        s.emplace(v[i].updates[j].time - 1, 0);
        bound =
            min(up(v[i].updates[j].time +
                   f64(damage - v[i].updates[j].health) / v[i].regen),
                j + 1 == v[i].updates.size() ? INF : v[i].updates[j + 1].time);
        s.emplace(bound - 1, 0);
        s.emplace(bound, 1);
        s.emplace(bound, -2);
      }
  }
  ant = sum = 0;
  for (auto i : s) {
    sum += i.second;
    if (i.second >= 0) ant = max(ant, (i.first * rate + bounty) * sum);
  }
  cout << ant << endl;
  return 0;
}
