#include <bits/stdc++.h>
const int MAXN = 10e6 + 6;
using namespace std;
long long pre1[MAXN];
long long pre2[MAXN];
pair<int, int> info[MAXN];
int main() {
  int n, a, b, c, d, st, len, x, y;
  cin >> n >> a >> b >> c >> d >> st >> len;
  pre1[0] = st;
  pre2[0] = st;
  for (int i = 1; i <= n; i++) {
    cin >> x >> y;
    info[i] = make_pair(x, y);
    if (y == 1) {
      pre1[i] = pre1[i - 1] + a;
      pre2[i] = pre2[i - 1] + c;
    } else {
      pre1[i] = pre1[i - 1] - b;
      pre2[i] = pre2[i - 1] - d;
    }
  }
  info[0] = make_pair(-1, -1);
  multiset<long long> se;
  int rp = 1;
  for (int lp = 0; lp <= n; lp++) {
    if (pre1[lp] < 0) {
      cout << -1 << endl;
      return 0;
    }
    if (lp) se.erase(se.find(pre2[lp]));
    while (info[rp].first - (info[lp].first + 1) < len && rp <= n) {
      se.insert(pre2[rp]);
      rp++;
    }
    if (se.size() == 0) {
      cout << info[lp].first + 1 << endl;
      return 0;
    }
    long long tmp = *se.begin();
    if (pre1[lp] + tmp - pre2[lp] >= 0) {
      cout << info[lp].first + 1 << endl;
      return 0;
    }
  }
  return 0;
}
