#include <bits/stdc++.h>
using namespace std;
vector<pair<long long, long long> > pp;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long n, a, b, c, d, start, len;
  long long p, q;
  long long x, y, z;
  int l;
  cin >> n >> a >> b >> c >> d >> start >> len;
  for (int i = 0; i < n; i++) {
    cin >> p >> q;
    pp.emplace_back(make_pair(p, q));
  }
  l = 0, x = y = z = start;
  while (l < n && pp[l].first < len) {
    if (pp[l].second == 1)
      x += c;
    else
      x -= d;
    y = min(x, y);
    l++;
  }
  if (y >= 0) {
    cout << 0 << endl;
    return 0;
  }
  for (int i = 0; i < n; i++) {
    if (pp[i].second == 1) {
      x += a - c;
      z += a;
      y += a - c;
    } else {
      x -= b - d;
      z -= b;
      y -= b - d;
    }
    if (z < 0) {
      cout << -1 << endl;
      return 0;
    }
    while (l < n && pp[i].first + len >= pp[l].first) {
      if (pp[l].second == 1)
        x += c;
      else
        x -= d;
      y = min(y, x);
      l++;
    }
    if (y >= 0) {
      cout << pp[i].first + 1 << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}
