#include <bits/stdc++.h>
using namespace std;
long n, npos;
long long a, b, c, d, start;
long len;
long long t[300010], sab[300010], scd[300010];
long q[300010];
long pos[2 * 300010];
long long M_ab[300010][20], M_cd[300010][20];
void build_RMQ(long long M[300010][20], long long A[300010], long N) {
  for (int i = 1; i <= N; i++) M[i][0] = i;
  for (int j = 1; 1 << j <= N; j++)
    for (int i = 1; i + (1 << j) - 1 <= N; i++) {
      if (A[M[i][j - 1]] < A[M[i + (1 << (j - 1))][j - 1]])
        M[i][j] = M[i][j - 1];
      else
        M[i][j] = M[i + (1 << (j - 1))][j - 1];
    }
}
long RMQ_find(long long M[300010][20], long long A[300010], int i, int j) {
  int k = int(log2(j - i + 1));
  if (A[M[i][k]] <= A[M[j - (1 << k) + 1][k]]) return M[i][k];
  return M[j - (1 << k) + 1][k];
}
int main() {
  cin >> n >> a >> b >> c >> d >> start >> len;
  sab[0] = start;
  scd[0] = start;
  for (int i = 1; i <= n; i++) {
    cin >> t[i] >> q[i];
    if (q[i] == 1) {
      sab[i] = sab[i - 1] + a;
      scd[i] = scd[i - 1] + c;
    } else {
      sab[i] = sab[i - 1] - b;
      scd[i] = scd[i - 1] - d;
    }
  }
  build_RMQ(M_ab, sab, n);
  build_RMQ(M_cd, scd, n);
  npos = 1;
  pos[1] = 0;
  for (int i = 1; i <= n; i++) {
    npos += 1;
    pos[npos] = t[i] + 1;
    if (t[i] - len + 1 > 0) {
      npos += 1;
      pos[npos] = t[i] - len + 1;
    }
  }
  sort(pos + 1, pos + npos + 1);
  for (int ipos = 1; ipos <= npos; ipos++) {
    long T = pos[ipos];
    long lo, hi, mid;
    long min_affect, max_affect;
    min_affect = n + 1;
    lo = 1;
    hi = n;
    while (lo <= hi) {
      mid = (lo + hi) / 2;
      if (t[mid] >= T) {
        min_affect = mid;
        hi = mid - 1;
      } else
        lo = mid + 1;
    }
    max_affect = n + 1;
    lo = min_affect;
    hi = n;
    while (lo <= hi) {
      mid = (lo + hi) / 2;
      if (t[mid] <= T + len - 1) {
        max_affect = mid;
        lo = mid + 1;
      } else
        hi = mid - 1;
    }
    long long part1, part2, part3;
    if (min_affect == 1)
      part1 = 0;
    else
      part1 = sab[RMQ_find(M_ab, sab, 1, min_affect - 1)];
    part2 = scd[RMQ_find(M_cd, scd, min_affect, max_affect)] -
            (scd[min_affect - 1] - sab[min_affect - 1]);
    if (part1 >= 0 && part2 >= 0) {
      cout << T;
      return 0;
    }
  }
  cout << -1;
  return 0;
}
