#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000002017;
const int N = 1010000;
int n, a, b, c, d, start, len;
long long rpref[N];
long long minpref[N], minsuf[N];
long long cnt[2][N];
int L, R;
int t[N], q[N];
vector<int> m;
multiset<long long> st;
long long getval(int j) {
  if (j < 0 || j > n) return 0ll;
  return cnt[1][j] * c - cnt[0][j] * d;
}
void del(int j) {
  long long val = getval(j);
  multiset<long long>::iterator it = st.find(val);
  st.erase(it);
}
void add(int j) {
  long long val = getval(j);
  st.insert(val);
}
long long getmin() {
  if (st.empty()) return 0ll;
  return (*st.begin());
}
bool check(int tL, int tR) {
  while (L <= n && t[L] < tL) {
    del(L);
    L++;
  }
  while (R < n && t[R + 1] <= tR) {
    R++;
    add(R);
  }
  if (R <= 0) {
    return (minpref[n] >= 0);
  }
  if (L > n) {
    return (minpref[n] >= 0);
  }
  if (L > R) {
    if (minpref[L - 1] < 0) return false;
    if (rpref[L - 1] + minsuf[R + 1] < 0) return false;
    return true;
  }
  if (minpref[L - 1] < 0) return false;
  long long val = rpref[L - 1];
  long long tmp = -cnt[1][L - 1] * c + cnt[0][L - 1] * d;
  long long valmin = val + tmp + getmin();
  if (valmin < 0) return false;
  return true;
}
int main() {
  scanf("%d%d%d%d%d%d%d", &n, &a, &b, &c, &d, &start, &len);
  for (int i = 1; i <= n; i++) scanf("%d%d", &t[i], &q[i]);
  rpref[0] = start;
  minpref[0] = start;
  for (int i = 1; i <= n; i++) {
    rpref[i] = rpref[i - 1] + (q[i] == 1 ? a : -b);
    minpref[i] = min(minpref[i - 1], rpref[i]);
  }
  minsuf[n + 1] = 0;
  for (int i = n; i >= 1; i--) {
    minsuf[i] = minsuf[i + 1] + (q[i] == 1 ? a : -b);
  }
  cnt[0][0] = cnt[1][0] = 0;
  for (int i = 1; i <= n; i++) {
    cnt[0][i] = cnt[0][i - 1];
    cnt[1][i] = cnt[1][i - 1];
    cnt[q[i]][i]++;
  }
  m.push_back(0);
  for (int i = 1; i <= n; i++) {
    m.push_back(t[i] + 1);
    if (t[i] - len + 1 >= 0) m.push_back(t[i] - len + 1);
  }
  sort(m.begin(), m.end());
  L = 1, R = 0;
  int res = -1;
  for (int i = 0; i < m.size(); i++) {
    if (i > 0 && m[i] == m[i - 1]) continue;
    int tcur = m[i];
    if (check(tcur, tcur + len - 1)) {
      res = tcur;
      break;
    }
  }
  cout << res;
  return 0;
}
