#include <bits/stdc++.h>
using namespace std;
template <class T>
bool umin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool umax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
pair<int, int> arr[300009];
long long DP[300009][2];
int n, a, b, c, d, st, len;
const long long baban = 1e15;
struct tree {
  long long s[300009 << 2];
  void build(int nd, int x, int y, int tp) {
    if (x == y) {
      s[nd] = DP[x][tp];
      return;
    }
    int mid = (x + y) >> 1;
    build(nd << 1, x, mid, tp);
    build(nd << 1 | 1, mid + 1, y, tp);
    s[nd] = min(s[nd << 1], s[nd << 1 | 1]);
  }
  long long tap(int l, int r, int nd, int x, int y) {
    if (l > r or l > y or x > r) return baban;
    if (l <= x and y <= r) return s[nd];
    int mid = (x + y) >> 1;
    return min(tap(l, r, nd << 1, x, mid), tap(l, r, nd << 1 | 1, mid + 1, y));
  }
} rap, par;
int julp(int x) {
  return upper_bound(arr + 1, arr + n + 1, make_pair(x, 1000000007)) - arr - 1;
}
bool solve(int l, int r) {
  return (rap.tap(1, l, 1, 1, n) + st >= 0 and
          st + DP[l][0] + par.tap(l + 1, r, 1, 1, n) - DP[l][1] >= 0);
}
int main() {
  scanf("%d%d%d%d%d%d%d", &n, &a, &b, &c, &d, &st, &len);
  for (int i = 1; i <= n; i++) {
    int t, p;
    scanf("%d%d", &t, &p);
    arr[i] = make_pair(t, p);
  }
  for (int i = 1; i <= n; i++) {
    if (!arr[i].second)
      DP[i][0] = DP[i - 1][0] - b;
    else
      DP[i][0] = DP[i - 1][0] + a;
  }
  rap.build(1, 1, n, 0);
  for (int i = 1; i <= n; i++) {
    if (!arr[i].second)
      DP[i][1] = DP[i - 1][1] - d;
    else
      DP[i][1] = DP[i - 1][1] + c;
  }
  par.build(1, 1, n, 1);
  if (solve(0, julp(0 + len))) return puts("0") * 0;
  for (int i = 1; i <= n; i++) {
    int t = arr[i].first;
    if (solve(i, julp(len + t + 1))) return printf("%d\n", t + 1) * 0;
  }
  puts("-1");
  return 0;
}
