#include <bits/stdc++.h>
using namespace std;
const int primero = 1 << 19;
const int tope = 1 << 20;
long long int suma[tope], minimo[tope];
void inserta(int pos, int val) {
  pos += primero;
  suma[pos] = val;
  minimo[pos] = val;
  while (pos > 1) {
    pos /= 2;
    suma[pos] = suma[2 * pos] + suma[2 * pos + 1];
    minimo[pos] = min(minimo[2 * pos], suma[2 * pos] + minimo[2 * pos + 1]);
  }
}
long long int minimoantes(int pos) {
  if (pos < 0) return 0;
  pos += primero;
  long long int mini = minimo[pos];
  while (pos > 1) {
    if (pos % 2 == 1) mini = min(minimo[pos - 1], suma[pos - 1] + mini);
    pos /= 2;
  }
  return mini;
}
int n, a, b, c, d, start, len;
pair<int, int> v[tope];
set<int> s;
int main() {
  ios::sync_with_stdio(false);
  cin >> n >> a >> b >> c >> d >> start >> len;
  s.insert(0);
  for (int i = 0; i < n; i++) {
    cin >> v[i].first >> v[i].second;
    if (v[i].second == 1)
      inserta(i, a);
    else
      inserta(i, -b);
    s.insert(v[i].first + 1);
    if (0 <= v[i].first - len + 1) s.insert(v[i].first - len + 1);
  }
  int i0 = 0, i1 = -1;
  for (set<int>::iterator it = s.begin(); it != s.end(); it++) {
    int le = *it;
    int ri = le + len - 1;
    while (i1 + 1 < n and v[i1 + 1].first <= ri) {
      i1++;
      if (v[i1].second == 1)
        inserta(i1, c);
      else
        inserta(i1, -d);
    }
    while (i0 < n and v[i0].first < le) {
      if (v[i0].second == 1)
        inserta(i0, a);
      else
        inserta(i0, -b);
      i0++;
    }
    if (start + minimoantes(i1) >= 0) {
      cout << le << endl;
      exit(0);
    }
  }
  cout << -1 << endl;
}
