#include <bits/stdc++.h>
using namespace std;
long long junger = 0, mid = 0, top = 0, bot = 0, result = 0, sum = 0, s = 0,
          t = 0, d = 0, l = 0, sp = 0, k = 0, x, y, n, m, test;
bool kt = false;
string s1, s2;
struct Zombie {
  long long maxH, staH, regen;
  vector<pair<long long, long long> > v;
};
Zombie z[100005];
long long bg[200005], ed[200005];
pair<int, pair<int, int> > a[100005];
int main() {
  long long bou, inc, dam, maxh, e, h;
  cin >> n >> m;
  cin >> bou >> inc >> dam;
  kt = true;
  for (long long(i) = (0); (i) < (n); (i)++) {
    scanf("%lld %lld %lld", &z[i].maxH, &z[i].staH, &z[i].regen);
    if (dam >= z[i].maxH) kt = false;
    if (z[i].regen != 0) {
      if (z[i].staH <= dam)
        z[i].v.push_back(make_pair(0, (dam - z[i].staH) / z[i].regen));
    } else {
      if (z[i].staH <= dam)
        z[i].v.push_back(make_pair(0, -1));
      else
        z[i].v.push_back(make_pair(-1, -1));
    }
  }
  for (long long(i) = (0); (i) < (m); (i)++)
    scanf("%lld %lld %lld", &a[i].first, &a[i].second.first,
          &a[i].second.second);
  sort(a, a + m);
  for (long long(i) = (0); (i) < (m); (i)++) {
    t = a[i].first;
    e = a[i].second.first;
    h = a[i].second.second;
    if (z[e - 1].regen != 0) {
      long long ed = (dam - h) / z[e - 1].regen + t;
      if (dam >= h) {
        if (z[e - 1].v.size() == 0) {
          z[e - 1].v.push_back(make_pair(t, ed));
        } else {
          if (z[e - 1].v[z[e - 1].v.size() - 1].second > t)
            z[e - 1].v[z[e - 1].v.size() - 1].second = ed;
          else
            z[e - 1].v.push_back(make_pair(t, ed));
        }
      } else {
        if (z[e - 1].v.size() != 0 &&
            z[e - 1].v[z[e - 1].v.size() - 1].second > t)
          z[e - 1].v[z[e - 1].v.size() - 1].second = t - 1;
      }
    } else {
      if (dam >= h) {
        if (z[e - 1].v[0].first == -1) z[e - 1].v[0].first = t;
        if (z[e - 1].v[z[e - 1].v.size() - 1].second != -1)
          z[e - 1].v.push_back(make_pair(t, -1));
      } else {
        if (z[e - 1].v[0].first != -1 &&
            z[e - 1].v[z[e - 1].v.size() - 1].second == -1)
          z[e - 1].v[z[e - 1].v.size() - 1].second = t - 1;
      }
    }
  }
  if (!kt && inc != 0) {
    cout << "-1";
    return 0;
  } else {
    d = 0;
    for (long long(i) = (0); (i) < (n); (i)++) {
      for (long long(j) = (0); (j) < (z[i].v.size()); (j)++) {
        if (z[i].v[j].first != -1) {
          if (z[i].v[j].second == -1) {
            if (inc != 0)
              kt = false;
            else
              ed[d] = z[i].v[j].second = 1e18;
          } else
            ed[d] = z[i].v[j].second;
          bg[d] = z[i].v[j].first;
          d++;
        }
      }
    }
    if (!kt && inc != 0) {
      cout << "-1";
      return 0;
    }
    sort(bg, bg + d);
    sort(ed, ed + d);
    long long dbg = 0, ded = 0, numZom = 0, maxMoney = 0;
    while (ded < d) {
      if (dbg < d && bg[dbg] <= ed[ded]) {
        numZom++;
        dbg++;
        while (dbg < d && bg[dbg] == bg[dbg - 1]) {
          dbg++;
          numZom++;
        }
      } else {
        maxMoney = max(maxMoney, numZom * (bou + inc * ed[ded]));
        numZom--;
        ded++;
        while (ded < d && ed[ded] == ed[ded - 1]) {
          ded++;
          numZom--;
        }
      }
    }
    cout << maxMoney;
  }
  return 0;
}
