#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
const int MAXN = 300000;
typedef struct QueueMinPrefSum {
  long long sum, sub;
  int lst[MAXN], head, tail;
  pair<long long, int> mn[MAXN];
  int mnhead, mntail;
  void init() {
    sum = sub = 0;
    head = tail = 0;
    mnhead = mntail = 0;
    mn[mnhead++] = make_pair(sum, head);
  }
  void print() {
    printf("sum=%lld sub=%lld lst=", sum, sub);
    for (int i = (tail); i < (head); ++i) printf("%d ", lst[i]);
    printf("mn=");
    for (int i = (mntail); i < (mnhead); ++i)
      printf(" %lld(%d)", mn[i].first, mn[i].second);
    puts("");
  }
  void push(int val) {
    sum += val;
    lst[head++] = val;
    while (mntail < mnhead && sum <= mn[mnhead - 1].first) --mnhead;
    mn[mnhead++] = make_pair(sum, head);
  }
  void pop() {
    sub += lst[tail];
    ++tail;
    while (mntail < mnhead && mn[mntail].second < tail) ++mntail;
  }
  long long val() {
    assert(mntail < mnhead);
    return mn[mntail].first - sub;
  }
} QueuePrefMin;
int n, gain1, lose0, talkgain1, talklose0, srating, len;
int et[MAXN], ekind[MAXN];
QueueMinPrefSum qmps;
void run() {
  scanf("%d%d%d%d%d%d%d", &n, &gain1, &lose0, &talkgain1, &talklose0, &srating,
        &len);
  for (int i = (0); i < (n); ++i) scanf("%d%d", &et[i], &ekind[i]);
  int t = 0, head = 0, tail = 0;
  long long rating = srating;
  qmps.init();
  while (true) {
    while (head < n && et[head] < t + len)
      qmps.push(ekind[head] == 0 ? -talklose0 : talkgain1), ++head;
    while (tail < head && et[tail] < t)
      rating += ekind[tail] == 0 ? -lose0 : gain1, qmps.pop(), ++tail;
    if (rating < 0) {
      printf("-1\n");
      return;
    }
    if (rating + qmps.val() >= 0) {
      printf("%d\n", t);
      return;
    }
    assert(tail < n && et[tail] >= t);
    t = et[tail] + 1;
  }
}
int main() {
  run();
  return 0;
}
