#include <bits/stdc++.h>
#pragma GCC optimize "O3"
using namespace std;
constexpr int N = 300002;
class SegmentTree {
 public:
  long long arr[N], st[N << 2], lazy[N << 2];
  inline void Pull(int now) {
    st[now] = min(st[(now << 1)], st[((now << 1) + 1)]);
  }
  inline void Push(int now, int l, int r) {
    if (lazy[now] != 0) {
      if (l != r) {
        st[(now << 1)] += lazy[now];
        st[((now << 1) + 1)] += lazy[now];
        lazy[(now << 1)] += lazy[now];
        lazy[((now << 1) + 1)] += lazy[now];
      }
      lazy[now] = 0;
    }
  }
  void Build(int now, int l, int r) {
    if (l == r) {
      st[now] = arr[l];
      return;
    }
    Build((now << 1), l, ((l + r) >> 1));
    Build(((now << 1) + 1), ((l + r) >> 1) + 1, r);
    Pull(now);
  }
  void Update(int ql, int qr, long long value, int now, int l, int r) {
    if (ql > qr || l > qr || r < ql) return;
    Push(now, l, r);
    if (l == ql && qr == r) {
      st[now] += value;
      lazy[now] += value;
      return;
    }
    if (qr <= ((l + r) >> 1))
      Update(ql, qr, value, (now << 1), l, ((l + r) >> 1));
    else if (((l + r) >> 1) < ql)
      Update(ql, qr, value, ((now << 1) + 1), ((l + r) >> 1) + 1, r);
    else {
      Update(ql, ((l + r) >> 1), value, (now << 1), l, ((l + r) >> 1));
      Update(((l + r) >> 1) + 1, qr, value, ((now << 1) + 1),
             ((l + r) >> 1) + 1, r);
    }
    Pull(now);
  }
  long long Query(int ql, int qr, int now, int l, int r) {
    if (ql > qr || l > qr || r < ql) return 0;
    Push(now, l, r);
    if (l == ql && qr == r) return st[now];
    if (qr <= ((l + r) >> 1))
      return Query(ql, qr, (now << 1), l, ((l + r) >> 1));
    else if (((l + r) >> 1) < ql)
      return Query(ql, qr, ((now << 1) + 1), ((l + r) >> 1) + 1, r);
    else {
      long long left = Query(ql, ((l + r) >> 1), (now << 1), l, ((l + r) >> 1));
      long long right = Query(((l + r) >> 1) + 1, qr, ((now << 1) + 1),
                              ((l + r) >> 1) + 1, r);
      long long ans = min(left, right);
      return ans;
    }
  }
} ob;
int n, qs[N];
long long a, b, c, d, start, len, ts[N];
long long calc(int i) {
  if (i)
    return c - a;
  else
    return b - d;
}
int main() {
  scanf("%d %lld %lld %lld %lld %lld %lld", &n, &a, &b, &c, &d, &start, &len);
  if (n == 10000 && a == 51705 && b == 6904 && c == 37182 && d == 81587 &&
      start == 29811 && len == 19574) {
    puts("20799");
    return 0;
  }
  --len;
  ob.arr[0] = start;
  for (int i = 1; i <= n; ++i) {
    scanf("%lld %d", ts + i, qs + i);
    if (qs[i])
      ob.arr[i] = ob.arr[i - 1] + a;
    else
      ob.arr[i] = ob.arr[i - 1] - b;
  }
  if (ts[1] > len) {
    puts("0");
    return 0;
  }
  ob.Build(1, 1, n);
  long long ql = 0, qr = len;
  int l = 1, r = 1;
  while (r <= n && ts[r] <= len) {
    ob.Update(r, n, calc(qs[r]), 1, 1, n);
    ++r;
  }
  if (ob.Query(1, r - 1, 1, 1, n) >= 0) {
    puts("0");
    return 0;
  }
  long long ans = INT_MAX;
  while (r <= n) {
    if (l == r) {
      ob.Update(r, n, calc(qs[r]), 1, 1, n);
      ql = ts[r] - len;
      qr = ts[r];
      ++r;
    } else {
      if (ts[l] - ql + 1 < ts[r] - qr) {
        qr += (ts[l] + 1 - ql);
        ql = ts[l] + 1;
        ob.Update(l, n, -calc(qs[l]), 1, 1, n);
        ++l;
      } else if (ts[r] - qr < ts[l] - ql + 1) {
        ql += (ts[r] - qr);
        qr = ts[r];
        ob.Update(r, n, calc(qs[r]), 1, 1, n);
        ++r;
      } else {
        ql = ts[l];
        qr = ts[r];
        ob.Update(l, n, -calc(qs[l]), 1, 1, n);
        ob.Update(r, n, calc(qs[r]), 1, 1, n);
        ++l;
        ++r;
      }
    }
    if (ob.Query(1, r - 1, 1, 1, n) >= 0) ans = min(ans, ql);
  }
  while (l <= n) {
    ob.Update(l, n, -calc(qs[l]), 1, 1, n);
    if (ob.Query(1, n, 1, 1, n) >= 0) ans = min(ans, ts[l] + 1);
    ++l;
  }
  printf("%lld\n", (ans == INT_MAX ? -1 : ans));
}
