#include <bits/stdc++.h>
using namespace std;
const int oo = 0x3f3f3f3f;
const long long ooo = 9223372036854775807ll;
const int _cnt = 1000 * 1000 + 7;
const int _p = 1000 * 1000 * 1000 + 7;
const int N = 300105;
const double PI = acos(-1.0);
const double eps = 1e-9;
int o(int x) { return x % _p; }
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
void file_put() {
  freopen("filename.in", "r", stdin);
  freopen("filename.out", "w", stdout);
}
struct ST {
  int n, log[N], dp[25][N];
  long long *a;
  int h(int x, int y) { return a[x] <= a[y] ? x : y; }
  void Init(int _n, long long *_a) {
    n = _n, a = _a, log[0] = -1;
    for (int i = (1); i <= (n); ++i) log[i] = log[i >> 1] + 1, dp[0][i] = i;
    for (int i = (1); i <= (log[n]); ++i)
      for (int j = (1); j <= (n + 1 - (1 << i)); ++j)
        dp[i][j] = h(dp[i - 1][j], dp[i - 1][j + (1 << (i - 1))]);
  }
  int Q(int l, int r) {
    int L = log[r - l + 1];
    return h(dp[L][l], dp[L][r + 1 - (1 << L)]);
  }
};
struct ttype {
  long long t;
  int q;
};
ttype t[N];
long long s[N], ss[N];
int n, a, b, c, d, start, l;
ST T;
bool cmp(ttype q, int x) { return q.t < x; }
int main() {
  scanf("%d%d%d%d%d%d%d", &n, &a, &b, &c, &d, &start, &l);
  s[0] = start;
  t[0].t = -1;
  for (int i = (1); i <= (n); ++i) scanf("%d%d", &t[i].t, &t[i].q);
  t[n + 1].t = ooo;
  ss[0] = 0;
  for (int i = (1); i <= (n); ++i) {
    s[i] = s[i - 1] + (t[i].q ? a : -b);
    ss[i] = ss[i - 1] + (t[i].q ? c : -d);
  }
  T.Init(n, ss);
  for (int i = (1); i <= (n); ++i) {
    if (s[i - 1] < 0) return 0 * printf("%d\n", -1);
    int t0 = t[i - 1].t + 1 + l;
    int y = lower_bound(t + 1, t + n + 2, t0, cmp) - t - 1;
    if (ss[T.Q(i, y)] - ss[i - 1] + s[i - 1] >= 0)
      return 0 * printf("%d\n", t[i - 1].t + 1);
  }
  if (s[n] < 0) return 0 * printf("%d\n", -1);
  printf("%I64d\n", t[n].t + 1);
  return 0;
}
