#include <bits/stdc++.h>
using namespace std;
static const int maxn = 3e5 + 5;
static const long long int inf = 1e18;
long long int n, a, b, c, d, start, len;
long long int tyme[maxn];
long long int type[maxn];
long long int cumsum1[maxn];
long long int cumsum2[maxn];
long long int increase[maxn];
long long int decrease[maxn];
template <typename T>
struct Node {
  T sum;
  T maxi;
  T mini;
  bool toset;
  bool toadd;
  T lazy;
  Node(T sum = 0, T maxi = numeric_limits<T>::min(),
       T mini = numeric_limits<T>::max(), bool toset = 0, bool toadd = 0,
       T lazy = 0)
      : sum(sum),
        maxi(maxi),
        mini(mini),
        toset(toset),
        toadd(toadd),
        lazy(lazy) {}
};
int arr[maxn];
template <typename T>
struct SegmentTree {
  int n;
  vector<Node<T> > st;
  void init(int N) {
    n = N;
    st.clear();
    st.resize(4 * N + 5);
  }
  void marge(int node, int a, int b) {
    st[node].sum = st[node * 2].sum + st[node * 2 + 1].sum;
    st[node].maxi = max(st[node * 2].maxi, st[node * 2 + 1].maxi);
    st[node].mini = min(st[node * 2].mini, st[node * 2 + 1].mini);
  }
  void build(int node, int a, int b) {
    if (a == b) {
      int val = arr[a];
      st[node].sum = val;
      st[node].maxi = val;
      st[node].mini = val;
      return;
    }
    build(node * 2, a, (int)(a + b) / 2);
    build(node * 2 + 1, (int)(a + b) / 2 + 1, b);
    marge(node, a, b);
  }
  void propagate1(int node, int a, int b) {
    if (a != b) {
      st[node * 2].toset = st[node * 2 + 1].toset = 1;
      st[node * 2].toadd = st[node * 2 + 1].toadd = 0;
      st[node * 2].lazy = st[node * 2 + 1].lazy = st[node].lazy;
    }
    st[node].maxi = st[node].mini = st[node].lazy;
    st[node].sum = 1LL * (b - a + 1) * st[node].lazy;
    st[node].toset = st[node].toadd = 0;
    st[node].lazy = 0;
  }
  void propagate2(int node, int a, int b) {
    if (a != b) {
      st[node * 2].toadd = st[node * 2 + 1].toadd = 1;
      st[node * 2].lazy += st[node].lazy;
      st[node * 2 + 1].lazy += st[node].lazy;
    }
    st[node].sum += 1LL * (b - a + 1) * st[node].lazy;
    st[node].maxi += st[node].lazy;
    st[node].mini += st[node].lazy;
    st[node].toadd = st[node].toset = 0;
    st[node].lazy = 0;
  }
  void update(int node, int a, int b, int i, int j, T val, bool toset) {
    if (st[node].toset) propagate1(node, a, b);
    if (st[node].lazy) propagate2(node, a, b);
    if (a > j or b < i) return;
    if (a >= i and b <= j) {
      if (toset) {
        st[node].toset = 1;
        st[node].toadd = 0;
        st[node].lazy = val;
        propagate1(node, a, b);
      } else {
        st[node].toset = 0;
        st[node].toadd = 1;
        st[node].lazy += val;
        propagate2(node, a, b);
      }
      return;
    }
    update(node * 2, a, (int)(a + b) / 2, i, j, val, toset);
    update(node * 2 + 1, (int)(a + b) / 2 + 1, b, i, j, val, toset);
    marge(node, a, b);
  }
  Node<T> query(int node, int a, int b, int i, int j) {
    if (st[node].toset) propagate1(node, a, b);
    if (st[node].toadd) propagate2(node, a, b);
    if (a > j or b < i) return Node<T>();
    if (a >= i and b <= j) return st[node];
    Node<T> p = query(node * 2, a, (int)(a + b) / 2, i, j);
    Node<T> q = query(node * 2 + 1, (int)(a + b) / 2 + 1, b, i, j);
    Node<T> res;
    res.sum = p.sum + q.sum;
    res.maxi = max(p.maxi, q.maxi);
    res.mini = min(p.mini, q.mini);
    marge(node, a, b);
    return res;
  }
  void build() { build(1, 1, n); }
  void uset(int l, int r, T val) { update(1, 1, n, l, r, val, 1); }
  void uadd(int l, int r, T val) { update(1, 1, n, l, r, val, 0); }
  Node<T> query(int l, int r) { return query(1, 1, n, l, r); }
  T get_sum(int l, int r) { return query(l, r).sum; }
  T get_maxi(int l, int r) { return query(l, r).maxi; }
  T get_mini(int l, int r) { return query(l, r).mini; }
};
SegmentTree<long long int> Tree1;
SegmentTree<long long int> Tree2;
bool solve1(long long int mytime, int l, int r) {
  if (r <= 0 or l > r) return true;
  l = max(l, 1);
  long long int mini = Tree1.get_mini(l, r);
  if (mytime + mini <= 0) return false;
  return true;
}
bool solve2(long long int mytime, int l, int r) {
  if (r <= 0 or l > r) return true;
  l = max(l, 1);
  long long int mini = Tree2.get_mini(l, r);
  if (mytime + mini <= 0) return false;
  return true;
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cin >> n >> a >> b >> c >> d >> start >> len;
  Tree1.init(n);
  Tree2.init(n);
  Tree1.uset(1, n, 0);
  Tree2.uset(1, n, 0);
  type[0] = 2;
  for (int i = 1; i <= n; i++) {
    cin >> tyme[i] >> type[i];
    increase[i] = increase[i - 1];
    decrease[i] = decrease[i - 1];
    if (type[i] == 1) {
      increase[i] += 1;
      Tree1.uadd(i, n, c);
      Tree2.uadd(i, n, a);
    } else {
      decrease[i] += 1;
      Tree1.uadd(i, n, -d);
      Tree2.uadd(i, n, -b);
    }
  }
  long long int total_time = start;
  tyme[0] = -1;
  for (int i = 1; i <= n; i++) {
    long long int LEFT = tyme[i];
    long long int RIGHT = tyme[i] + len - 1;
    long long int lo = i;
    long long int hi = n;
    long long int j = -1;
    while (lo <= hi) {
      long long int md = (lo + hi) / 2;
      if (tyme[md] <= RIGHT)
        j = md, lo = md + 1;
      else
        hi = md - 1;
    }
    long long int mytime = total_time;
    bool ok = solve1(mytime, i, j);
    if (ok == true) {
      cout << tyme[i - 1] + 1;
      return 0;
    }
    if (i > 0) {
      if (type[i] == 1) {
        Tree1.uadd(i, n, -c);
        Tree2.uadd(i, n, -a);
        total_time += a;
      } else {
        Tree1.uadd(i, n, d);
        Tree2.uadd(i, n, b);
        total_time -= b;
      }
    }
    if (total_time < 0) {
      cout << -1;
      return 0;
    }
  }
  cout << tyme[n] + 1;
}
