#include <bits/stdc++.h>
using namespace std;
struct X {
  long long sum, prefix;
  X operator+(const X &oth) const {
    return {sum + oth.sum, min(prefix, sum + oth.prefix)};
  }
  void set(long long a) { sum = prefix = a; }
} st[300005 * 2];
long long a, b, c, d, n, start, len;
long long type[300005], sum[300005];
bool check[300005];
vector<long long> etime;
void build() {
  sum[0] = start + (type[0] ? a : -b);
  check[0] = sum[0] >= 0;
  for (int i = 1; i < n; i++) {
    sum[i] = sum[i - 1] + (type[i] ? a : -b);
    if (sum[i] >= 0)
      check[i] = check[i - 1];
    else
      check[i] = false;
  }
  for (int i = 0; i < n; i++) st[n + i].set(type[i] ? c : -d);
  for (int i = n - 1; i; i--) st[i] = st[i << 1] + st[i << 1 | 1];
}
X rmq(int l, int r) {
  X retl = {0, 0}, retr = {0, 0};
  for (l += n, r += n; l < r; l >>= 1, r >>= 1) {
    if (l & 1) retl = retl + st[l++];
    if (r & 1) retr = st[--r] + retr;
  }
  return retl + retr;
}
int main() {
  cin >> n >> a >> b >> c >> d >> start >> len;
  for (int i = 0; i < n; i++) {
    long long x;
    cin >> x;
    etime.push_back(x);
    cin >> type[i];
  }
  build();
  vector<long long> t;
  t.push_back(0);
  for (int i = 0; i < n; i++) {
    t.push_back(etime[i] + 1);
  }
  for (int i = 0; i < t.size(); i++) {
    int l = lower_bound(etime.begin(), etime.end(), t[i]) - etime.begin();
    int r =
        upper_bound(etime.begin(), etime.end(), t[i] + len - 1) - etime.begin();
    if (l > 0 && !check[l - 1]) continue;
    if ((l == 0 ? start : sum[l - 1]) + rmq(l, r).prefix < 0) continue;
    cout << t[i] << endl;
    return 0;
  }
  cout << -1 << endl;
  return 0;
}
