#include <bits/stdc++.h>
using namespace std;
const int N = 1000005;
int n, m;
long long A, B, limit, tim[N], mx[N], st[N], ad[N];
int vst[N];
long long mh[N];
struct node {
  int i, x, w, tag;
  long long t;
} p[N];
int top = 0;
bool cmp(const node p1, const node p2) {
  if (p1.t == p2.t) return p1.tag > p2.tag;
  return p1.t < p2.t;
}
int main() {
  scanf("%d%d", &n, &m);
  scanf("%I64d%I64d%I64d", &B, &A, &limit);
  int i, x;
  long long t, j;
  int spe = 0;
  long long ans = 0, sum = 0;
  for (i = 1; i <= n; i++) {
    scanf("%I64d%I64d%I64d", &mx[i], &st[i], &ad[i]);
    if (ad[i])
      mh[i] = mx[i];
    else
      mh[i] = st[i];
    if (mx[i] <= limit)
      sum++, vst[i] = 1, tim[i] = -1, spe = 1;
    else if (st[i] <= limit) {
      sum++;
      vst[i] = 1;
      if (ad[i]) {
        top++;
        p[top].i = i;
        p[top].t = (limit - st[i]) / ad[i];
        p[top].tag = 0;
        tim[i] = p[top].t;
        top++;
        p[top].tag = 1;
        p[top].t = p[top - 1].t;
      } else
        tim[i] = -1;
    }
  }
  for (i = 1; i <= m; i++) {
    scanf("%I64d%d%I64d", &t, &x, &j);
    if (ad[x])
      mh[x] = mx[x];
    else
      mh[x] = j;
    if (mx[x] <= limit) continue;
    top++;
    p[top].tag = 1;
    p[top].t = t;
    top++;
    p[top].tag = 1;
    p[top].t = t - 1;
    top++;
    p[top].i = x;
    p[top].t = t;
    p[top].tag = 2;
    p[top].w = j;
    if (j <= limit) {
      if (ad[x]) {
        top++;
        p[top].i = x;
        p[top].t = t + (limit - j) / ad[x];
        p[top].tag = 0;
        top++;
        p[top].tag = 1;
        p[top].t = p[top - 1].t;
      }
    }
  }
  for (i = 1; i <= n; i++)
    if (mh[i] <= limit && A != 0) {
      printf("-1");
      return 0;
    }
  if (spe == 1 && A != 0) {
    printf("-1");
    return 0;
  }
  sort(p + 1, p + top + 1, cmp);
  ans = max(ans, sum * B);
  for (i = 1; i <= top; i++) {
    x = p[i].i;
    t = p[i].t;
    if (p[i].tag == 0) {
      if (tim[x] != t) continue;
      if (!vst[x]) continue;
      sum--;
      vst[x] = 0;
      tim[x] = -1;
    }
    if (p[i].tag == 2) {
      j = p[i].w;
      if (j <= limit) {
        if (!vst[x]) sum++;
        vst[x] = 1;
        if (ad[x])
          tim[x] = t + (limit - j) / ad[x];
        else
          tim[x] = -1;
      } else {
        if (vst[x]) sum--;
        vst[x] = 0;
        tim[x] = -1;
      }
    }
    if (p[i].tag == 1) {
      ans = max(ans, (long long)A * t * sum + sum * B);
    }
  }
  printf("%I64d", ans);
  return 0;
}
