#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vll = vector<ll>;
using pill = pair<int, ll>;
using vvi = vector<vi>;
ll gcd(ll a, ll b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
ll fast_exp(ll base, ll n, ll m) {
  if (n == 0) return 1;
  ll t = fast_exp(base, n / 2, m);
  if (n % 2 == 0)
    return (t * t) % m;
  else
    return (((t * t) % m) * base) % m;
}
int main() {
  ios::sync_with_stdio(false);
  int n, a, b, c, d, start, len;
  cin >> n >> a >> b >> c >> d >> start >> len;
  map<int, int> tmap;
  tmap[0] = 0;
  ll ro = start, rn = 0;
  vll v0, v1;
  v0.push_back(ro), v1.push_back(rn);
  int l = n + 1;
  vi shift;
  shift.push_back(0);
  for (int i = 1; i <= n; ++i) {
    int t, q;
    cin >> t >> q;
    tmap[i] = t;
    ro += q ? a : -b;
    rn += q ? c : -d;
    shift.push_back(q ? c : -d);
    if (ro < 0) l = min(l, i);
    v0.push_back(ro), v1.push_back(rn);
  }
  tmap[n + 1] = tmap[n] + 1;
  v0.push_back(v0.back()), v1.push_back(v1.back());
  shift.push_back(0);
  vll sml;
  multiset<ll> S;
  map<int, decltype(S.begin())> foo;
  int i = 0, j = 0;
  while (i <= l) {
    while (j <= n + 1 and tmap[j] - tmap[i] < len)
      foo[j] = S.insert(v1[j]), ++j;
    sml.push_back(*S.begin() - v1[i] + shift[i]);
    S.erase(foo[i]);
    ++i;
  }
  for (int i = 1; i <= l; ++i)
    if (sml[i] + v0[i - 1] >= 0) {
      cout << tmap[i - 1] + (i > 1 ? 1 : 0) << "\n";
      return 0;
    }
  cout << "-1\n";
  return 0;
}
