#include <bits/stdc++.h>
using namespace std;
struct SegTree {
  int size;
  vector<long long> seg;
  SegTree() {}
  SegTree(int size) {
    this->size = size;
    seg.resize(1 << (size + 1));
  }
  void init() {
    for (int i = 0; i < (1 << (size + 1)); i++) seg[i] = 1e18;
  }
  void update(int i, long long val) {
    i += (1 << size);
    seg[i] = val;
    while (i > 1) {
      i /= 2;
      seg[i] = min(seg[i * 2], seg[i * 2 + 1]);
    }
  }
  long long query(int a, int b, int k, int l, int r) {
    if (b < l || r < a) return 1e18;
    if (a <= l && r <= b) return seg[k];
    long long lval = query(a, b, k * 2, l, (l + r) / 2);
    long long rval = query(a, b, k * 2 + 1, (l + r) / 2 + 1, r);
    return min(lval, rval);
  }
  long long query(int a, int b) {
    if (a > b) return 1e18;
    return query(a, b, 1, 0, (1 << size) - 1);
  }
};
long long n, a, b, c, d, s, len;
long long t[300005], q[300005];
long long h[300005], h2[300005];
SegTree seg(19), seg2(19);
void make(long long a, long long b, long long h[]) {
  for (long long(i) = (1); (i) <= (n); (i)++) {
    h[i] = h[i - 1];
    if (q[i] == 1)
      h[i] += a;
    else
      h[i] -= b;
  }
}
bool check(long long x) {
  long long l = lower_bound(t + 1, t + n + 1, x) - t;
  long long r = lower_bound(t + 1, t + n + 1, x + len) - t - 1;
  long long H = s;
  if (seg.query(0, l - 1) + H < 0) return false;
  H += h[l - 1];
  if (seg2.query(l, r) - h2[l - 1] + H < 0) return false;
  return true;
}
int main(void) {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> a >> b >> c >> d >> s >> len;
  for (long long(i) = (1); (i) <= (n); (i)++) cin >> t[i] >> q[i];
  make(a, b, h);
  make(c, d, h2);
  seg.init(), seg2.init();
  for (long long(i) = (0); (i) <= (n); (i)++)
    seg.update(i, h[i]), seg2.update(i, h2[i]);
  set<long long> S;
  S.insert(0);
  for (long long(i) = (1); (i) <= (n); (i)++)
    S.insert(max(0LL, t[i] - len + 1));
  for (long long(i) = (1); (i) <= (n); (i)++) S.insert(max(0LL, t[i] + 1));
  for (auto x : S) {
    if (check(x)) {
      cout << x << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}
