#include <bits/stdc++.h>
using namespace std;
const int MAXN = 3e5 + 7;
long long int n, a, b, c, d, start, len;
int t[MAXN], q[MAXN];
int fr = 1, re = 1;
long long now, sum1[MAXN], sum2[MAXN];
multiset<long long> tree;
bool check() {
  if (tree.empty()) return true;
  long long now = start + *tree.begin();
  return now + sum1[fr - 1] - sum2[fr - 1] >= 0;
}
int main() {
  scanf("%I64d%I64d%I64d%I64d%I64d%I64d%I64d", &n, &a, &b, &c, &d, &start,
        &len);
  for (int i = 1; i <= n; i++) {
    scanf("%d%d", &t[i], &q[i]);
    if (q[i]) {
      sum1[i] = sum1[i - 1] + a;
      sum2[i] = sum2[i - 1] + c;
    } else {
      sum1[i] = sum1[i - 1] - b;
      sum2[i] = sum2[i - 1] - d;
    }
  }
  long long le = 0, ri = len;
  while (re <= n && t[re] < ri) {
    tree.insert(sum2[re++]);
  }
  while (!check()) {
    if (start + sum1[fr] < 0) {
      puts("-1");
      return 0;
    }
    le = t[fr] + 1;
    tree.erase(tree.find(sum2[fr]));
    fr++;
    ri = le + len;
    while (re <= n && t[re] < ri) {
      tree.insert(sum2[re++]);
    }
  }
  printf("%I64d\n", le);
  return 0;
}
