#include <bits/stdc++.h>
using namespace std;
long long int notalk[300100], talk[300100];
long long int tab[300100];
signed main() {
  long long int n, a, b, c, d, start, len;
  cin >> n >> a >> b >> c >> d >> start >> len;
  talk[0] = notalk[0] = start;
  for (long long int i = 0; i < n; i++) {
    long long int t, q;
    cin >> t >> q;
    tab[i] = t;
    if (q == 1) {
      notalk[i + 1] = notalk[i] + a;
      talk[i + 1] = talk[i] + c;
    } else {
      notalk[i + 1] = notalk[i] - b;
      talk[i + 1] = talk[i] - d;
    }
  }
  long long int p_left = 0, p_right = 0;
  for (; p_left <= n;) {
    long long int T;
    if (p_left == 0)
      T = 0;
    else
      T = tab[p_left - 1] + 1;
    if (p_right == n || T + len < tab[p_right]) {
      cout << T << endl;
      return 0;
    }
    long long int r = (talk[p_right + 1] - talk[p_left]) + notalk[p_left];
    if (r < 0) {
      if (notalk[p_left] < 0) {
        cout << -1 << endl;
        return 0;
      }
      p_left++;
    } else {
      p_right++;
    }
  }
  cout << -1 << endl;
  return 0;
}
