#include <bits/stdc++.h>
using namespace std;
int const N = int(3e5) + 7;
int const mod = int(1e9) + 7;
vector<pair<int, int>> v;
long long fs[N];
long long ss[N];
int main() {
  ios_base::sync_with_stdio(false);
  ifstream in("input.txt");
  int n, a, b, c, d;
  int st, len;
  cin >> n >> a >> b >> c >> d;
  cin >> st >> len;
  for (int i = 0; i < n; ++i) {
    int t, q;
    cin >> t >> q;
    v.push_back(make_pair(t, q));
  }
  sort(v.begin(), v.end());
  for (int i = 0; i < n; ++i) {
    if (v[i].second) {
      fs[i + 1] = fs[i] + a;
      ss[i + 1] = ss[i] + c;
    } else {
      fs[i + 1] = fs[i] - b;
      ss[i + 1] = ss[i] - d;
    }
  }
  int r = 0;
  map<long long, int> mm;
  int l = 0;
  for (int i = 0; i < n; ++i) {
    if (st + fs[i] < 0) {
      cout << -1;
      return 0;
    }
    while (r < n && v[r].first - l < len) {
      ++mm[ss[r + 1]];
      ++r;
    }
    long long val = mm.begin()->first;
    if (st + fs[i] >= 0 && st + fs[i] + val - ss[i] >= 0) {
      cout << l;
      return 0;
    }
    --mm[ss[i + 1]];
    if (mm[ss[i + 1]] == 0) {
      mm.erase(ss[i + 1]);
    }
    l = v[i].first + 1;
  }
  if (st + fs[n] >= 0) {
    cout << v[n - 1].first + 1;
    return 0;
  }
  cout << -1;
  return 0;
}
