#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ui = unsigned int;
const int NMax = 3e5 + 5;
const ll inf = 1e18 + 5;
const int mod = 100003;
using zint = int;
ll N, a, b, c, d, start, len;
ll dpAB[NMax], dpCD[NMax];
pair<ll, ll> v[NMax];
int main() {
  cin.sync_with_stdio(false);
  cin.tie(0);
  cin >> N >> a >> b >> c >> d >> start >> len;
  dpAB[0] = dpCD[0] = start;
  for (int i = 1; i <= N; ++i) {
    cin >> v[i].first >> v[i].second;
    if (v[i].second == 1) {
      dpAB[i] = dpAB[i - 1] + a;
      dpCD[i] = dpCD[i - 1] + c;
    } else {
      dpAB[i] = dpAB[i - 1] - b;
      dpCD[i] = dpCD[i - 1] - d;
    }
  }
  v[0] = make_pair(-1, 0);
  int j = 0;
  multiset<ll> st;
  for (int i = 0; i <= N; ++i) {
    if (dpAB[i] < 0) {
      cout << "-1";
      return 0;
    }
    if (i != 0) {
      st.erase(st.find(dpCD[i]));
    }
    while (j <= N && v[j].first < (v[i].first + 1) + len) {
      ll val = dpCD[j];
      st.insert(val);
      ++j;
    }
    ll min = *(st.begin());
    if (dpAB[i] + (min - dpCD[i]) > 0) {
      cout << v[i].first + 1 << '\n';
      return 0;
    }
  }
  return 0;
}
