#include <bits/stdc++.h>
using namespace std;
int T[300000];
int Q[300000];
long long F[300010];
long long B[300010];
long long M[19][300010];
int n, a, b, c, d, start, len;
long long get(int i, int l) {
  int z;
  for (z = 20; z > 0; --z)
    if (l & (1 << z)) break;
  return max(M[z][i], M[z][i + l - (1 << z)]);
}
bool check(int t, int i, int j) {
  if ((i != 0 && T[i - 1] >= t) || (i < n && T[i] < t) ||
      (j != 0 && T[j - 1] >= t + len) || (j < n && T[j] < t + len)) {
    printf("error %d %d %d\n", t, i, j);
    throw "qwe";
  }
  return (F[i] + B[i] - get(i, j - i + 1) >= 0);
}
int solve() {
  scanf("%d%d%d%d%d%d%d", &n, &a, &b, &c, &d, &start, &len);
  for (int i = 0; i < n; ++i) scanf("%d%d", &T[i], &Q[i]);
  long long s = 0;
  F[0] = start;
  for (int i = 0; i < n; ++i) F[i + 1] = F[i] + (Q[i] == 1 ? a : -b);
  B[n] = 0;
  for (int i = n - 1; i >= 0; --i) B[i] = B[i + 1] + (Q[i] == 1 ? c : -d);
  for (int i = n; i >= 0; --i) {
    M[0][i] = B[i];
  }
  for (int j = 0; j < 18; ++j) {
    for (int i = n + 1 - (2 << j); i >= 0; --i) {
      M[j + 1][i] = max(M[j][i], M[j][i + (1 << j)]);
    }
  }
  int t = 0;
  int i = 0;
  int j = 0;
  bool docheck = true;
  for (;;) {
    while (i < n && T[i] < t) {
      ++i;
      if (F[i] < 0) return -1;
    }
    while (j < n && T[j] < t + len) ++j;
    if (docheck) {
      if (check(t, i, j)) return t;
      docheck = false;
    }
    if (i < n && j < n) {
      if (T[i] + 1 < T[j] - len + 1) {
        t = T[i] + 1;
        docheck = true;
      } else {
        t = T[j] - len + 1;
      }
    } else if (i < n) {
      t = T[i] + 1;
      docheck = true;
    } else if (j < n)
      t = T[j] - len + 1;
    else
      break;
  }
  if (check(t, i, j)) return t;
  return -1;
}
int main() {
  printf("%d", solve());
  return 0;
}
