#include <bits/stdc++.h>
using namespace std;
typedef struct {
  long long int v1, v2;
} it;
int main() {
  long long int n, a, b, c1, d, start, len;
  cin >> n >> a >> b >> c1 >> d >> start >> len;
  vector<it> c(n);
  for (int i = 0; i < n; i++) {
    cin >> c[i].v1 >> c[i].v2;
  }
  long long int f = len, s = 0, sum = start, e = -1;
  for (int i = 0; i < n; i++) {
    if (c[i].v2 == 1) {
      sum += a;
    } else {
      sum -= b;
    }
    if (sum < 0) {
      e = c[i].v1;
      break;
    }
  }
  if (e == -1) e = c[n - 1].v1 + 1;
  int st = 0;
  int i = st;
  sum = start;
  while (c[i].v1 < f && s < e && i < n) {
    if (c[i].v2 == 1) {
      sum += c1;
    } else {
      sum -= d;
    }
    if (sum < 0) {
      s = c[st].v1 + 1;
      f = c[st].v1 + 1 + len;
      if (c[st].v2 == 1) {
        sum -= c1;
        sum += a;
      } else {
        sum += d;
        sum -= b;
      }
      if (i != st) {
        if (c[i].v2 == 1) {
          sum -= c1;
        } else {
          sum += d;
        }
        i--;
      }
      st++;
    }
    i++;
  }
  if (s > e)
    cout << -1;
  else
    cout << s;
}
