#include <bits/stdc++.h>
using namespace std;
const int MAX = 12e5 + 5;
long long tim[MAX];
int typ[MAX];
int up[MAX];
long long dif[MAX];
long long dif2[MAX];
int fin[MAX];
int mrk[MAX];
int mrk2[MAX];
map<long long, int> mp;
int rev[MAX];
const int LIM = 48e5 + 5;
long long seg2[LIM];
long long seg1[LIM];
void combine(int t) {
  seg1[t] = min(seg1[t * 2], seg1[t * 2 + 1]);
  seg2[t] = min(seg2[t * 2], seg2[t * 2 + 1]);
}
void build(int t, int i, int j) {
  if (i == j) {
    seg1[t] = dif[i];
    seg2[t] = dif2[i];
    return;
  }
  int mid = (i + j) / 2;
  build(t * 2, i, mid);
  build(t * 2 + 1, mid + 1, j);
  combine(t);
}
long long query1(int t, int i, int j, int l, int r) {
  if (i > r || j < l) {
    return 1e18;
  }
  if (l <= i && j <= r) {
    return seg1[t];
  }
  int mid = (i + j) / 2;
  long long a = query1(t * 2, i, mid, l, r);
  long long b = query1(t * 2 + 1, mid + 1, j, l, r);
  return min(a, b);
}
long long query2(int t, int i, int j, int l, int r) {
  if (i > r || j < l) {
    return 1e18;
  }
  if (l <= i && j <= r) {
    return seg2[t];
  }
  int mid = (i + j) / 2;
  long long a = query2(t * 2, i, mid, l, r);
  long long b = query2(t * 2 + 1, mid + 1, j, l, r);
  return min(a, b);
}
int main() {
  int n;
  long long a, b, c, d, st, len;
  scanf("%d %lld %lld %lld %lld %lld %lld", &n, &a, &b, &c, &d, &st, &len);
  for (int i = 1; i <= n; i++) {
    scanf("%lld %d", &tim[i], &typ[i]);
    mp[tim[i]];
    if ((tim[i] - len + 1) >= 0) {
      mp[tim[i] + len - 1];
    }
    mp[tim[i] + 1];
    mp[tim[i] + len];
  }
  mp[0];
  mp[len - 1];
  int cur = 0;
  for (auto it : mp) {
    mp[it.first] = (++cur);
    fin[cur] = it.first;
  }
  for (int i = 1; i <= n; i++) {
    if ((tim[i] - len + 1) >= 0) {
      mp[tim[i] - len + 1];
      mrk2[mp[tim[i] - len + 1]] = 1;
      up[mp[tim[i] - len + 1]] = mp[tim[i]];
    }
    mrk2[mp[tim[i] + 1]] = 1;
    up[mp[tim[i] + 1]] = mp[tim[i] + len];
    mrk[mp[tim[i]]] = 1;
    rev[mp[tim[i]]] = i;
  }
  mrk2[1] = 1;
  up[1] = mp[len - 1];
  dif[0] = st;
  dif2[0] = st;
  for (int i = 1; i <= cur; i++) {
    if (mrk[i]) {
      if (typ[rev[i]] == 0) {
        dif[i] = dif[i - 1] - b;
        dif2[i] = dif2[i - 1] - d;
      } else {
        dif[i] = dif[i - 1] + a;
        dif2[i] = dif2[i - 1] + c;
      }
    } else {
      dif[i] = dif[i - 1];
      dif2[i] = dif2[i - 1];
    }
  }
  build(1, 1, cur);
  for (int i = 1; i <= cur; i++) {
    if (mrk2[i]) {
      if (i > 1) {
        if (query1(1, 1, cur, 1, i - 1) < 0) {
          continue;
        }
      }
      long long val = dif[i - 1];
      if ((query2(1, 1, cur, i, up[i]) - dif2[i - 1] + val) < 0) {
        continue;
      }
      printf("%d\n", fin[i]);
      return 0;
    }
  }
  printf("-1\n");
  return 0;
}
