#include <bits/stdc++.h>
using namespace std;
int a, b, c, d, n, start, len;
int t[300010], type[300010];
int main() {
  bool judge = false;
  cin >> n >> a >> b >> c >> d >> start >> len;
  for (int i = 0; i < n; i++) {
    scanf("%d%d", &t[i], &type[i]);
  }
  long long ans = start, mmin = 0, score = 0, now = 0;
  for (int i = 0; i < n; i++) {
    while (now < n && t[now] - t[i] < len) {
      if (type[now] == 1)
        score += c;
      else
        score -= d;
      mmin = min(mmin, score);
      now++;
    }
    if (ans + mmin >= 0) {
      if (i == 0)
        cout << 0 << endl;
      else
        cout << t[i - 1] + 1 << endl;
      judge = true;
      break;
    }
    if (type[i] == 1) {
      ans += a;
      mmin -= c;
      score -= c;
    } else {
      ans -= b;
      mmin += d;
      score += d;
    }
    if (ans < 0) {
      cout << -1 << endl;
      judge = true;
      break;
    }
  }
  if (!judge) {
    cout << t[n - 1] + 1 << endl;
  }
  return 0;
}
