#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 5;
const int X = 19;
long long T[N], Q[N];
vector<long long> gt;
long long ra[N], rc[N];
long long ram[N][X], rcm[N][X];
void _init(int n, long long ra[], long long ram[][X]) {
  for (int i = n; i >= 0; i--) {
    ram[i][0] = ra[i];
    for (int j = 1; j < X; j++) {
      if (i + (1 << j) - 1 > n) break;
      ram[i][j] = min(ram[i][j - 1], ram[i + (1 << (j - 1))][j - 1]);
    }
  }
}
long long _min(int a, int b, long long ram[][X]) {
  if (a > b) return 1e18;
  int j = log2(b - a + 1);
  return min(ram[a][j], ram[b - (1 << j) + 1][j]);
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  long long a, b, c, d, start, len;
  gt.push_back(0);
  cin >> n >> a >> b >> c >> d >> start >> len;
  for (int i = 1; i <= n; i++) {
    cin >> T[i] >> Q[i];
    gt.push_back(max(0LL, T[i] - len + 1));
    gt.push_back(T[i] + 1);
    ra[i] = ra[i - 1];
    rc[i] = rc[i - 1];
    if (Q[i]) {
      ra[i] += a;
      rc[i] += c;
    } else {
      ra[i] -= b;
      rc[i] -= d;
    }
  }
  _init(n, ra, ram);
  _init(n, rc, rcm);
  sort(gt.begin(), gt.end());
  gt.resize(unique(gt.begin(), gt.end()) - gt.begin());
  long long ans = -1;
  for (auto t : gt) {
    int l = lower_bound(T + 1, T + n + 1, t) - T;
    int r = lower_bound(T + 1, T + n + 1, t + len) - T;
    long long rat = start;
    if (_min(0, l - 1, ram) - ra[0] + rat < 0) continue;
    rat = ra[l - 1] - ra[0] + rat;
    if (_min(l - 1, r - 1, rcm) - rc[l - 1] + rat < 0) continue;
    ans = t;
    break;
  }
  cout << ans << "\n";
  return 0;
}
