#include <bits/stdc++.h>
using namespace std;
const long long INF = 2000000000000000;
long long t[300010];
int q[300010];
long long sum[300010];
int main() {
  long long n, a, b, c, d, start, len;
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> n >> a >> b >> c >> d >> start >> len;
  sum[0] = start;
  for (int i = 0; i < n; ++i) {
    cin >> t[i] >> q[i];
    sum[i + 1] = q[i] ? sum[i] + a : sum[i] - b;
  }
  long long T = 0;
  int curl = 0;
  int curr = 0;
  long long r = T + len;
  long long curv = start;
  set<long long> st;
  st.insert(start);
  while (curr < n && t[curr] < r) {
    curv += q[curr] ? c : -d;
    st.insert(curv);
    ++curr;
  }
  long long dd = 0;
  while (true) {
    r = T + len;
    if (*st.begin() + dd >= 0) {
      cout << T;
      return 0;
    }
    long long dl = curl >= n ? INF : t[curl] - T + 1;
    long long dr = curr >= n ? INF : t[curr] - r + 1;
    if (dl == INF) break;
    if (dl <= dr) {
      long long t = q[curl] ? a - c : d - b;
      curv += t;
      st.erase(sum[curl + 1] - t - dd);
      dd += q[curl] ? a - c : d - b;
      if (sum[curl + 1] < 0) {
        cout << -1;
        return 0;
      }
      ++curl;
    }
    if (dr <= dl) {
      curv += q[curr] ? c : -d;
      st.insert(curv - dd);
      ++curr;
    }
    T += min(dl, dr);
  }
  cout << -1;
  return 0;
}
