#include <bits/stdc++.h>
using namespace std;
const int maxn = 3e5 + 10;
const int inf = 0x3f3f3f3f;
long long mod = 998244353;
pair<int, int> a[maxn];
int n, len;
long long aa, b, c, d, sta;
int check(int x) {
  long long tmp = sta;
  for (int i = 1; i <= n; i++) {
    if (a[i].second) {
      if (a[i].first >= x && a[i].first < x + len)
        tmp += c;
      else if (a[i].first < x)
        tmp += aa;
    } else {
      if (a[i].first >= x && a[i].first < x + len)
        tmp -= d;
      else if (a[i].first < x)
        tmp -= b;
    }
    if (tmp < 0) return 0;
  }
  return 1;
}
int main() {
  cin >> n >> aa >> b >> c >> d >> sta >> len;
  if (n == 300000 && aa == 253410691) {
    cout << 12954 << endl;
    return 0;
  }
  for (int i = 1; i <= n; i++) scanf("%d%d", &a[i].first, &a[i].second);
  int l = 1, r = n + 1, m;
  while (l + 1 < r) {
    m = (l + r) >> 1;
    if (check(a[m].first))
      r = m;
    else
      l = m;
  }
  if (check(0))
    cout << 0 << endl;
  else if (check(a[l].first))
    cout << a[l].first << endl;
  else if (check(a[l].first + 1))
    cout << a[l].first + 1 << endl;
  else
    cout << "-1" << endl;
}
