#include <bits/stdc++.h>
using namespace std;
long long sum[300005];
void solve() {
  int n, a, b, c, d, start, len;
  scanf("%d %d %d %d %d %d %d", &n, &a, &b, &c, &d, &start, &len);
  vector<pair<int, int> > in;
  for (int i = 0; i < n; ++i) {
    int t, type;
    scanf("%d %d ", &t, &type);
    in.push_back({t, type});
  }
  in.push_back({-1, -1});
  sort(in.begin(), in.end());
  for (int i = 0; i < in.size(); ++i) {
    int add = 0;
    if (in[i].second == 0) {
      add = -d;
    } else if (in[i].second == 1) {
      add = c;
    }
    sum[i + 1] = sum[i] + add;
  }
  multiset<pair<long long, int> > s;
  int pos = 0;
  long long curSum = start;
  for (int i = 0; i < in.size(); ++i) {
    int cur = in[i].first + 1;
    int add = 0;
    if (in[i].second == 0) {
      add = -b;
    } else if (in[i].second == 1) {
      add = a;
    }
    curSum += add;
    if (curSum < 0) {
      printf("-1\n");
      return;
    }
    while (pos < in.size()) {
      if (in[pos].first <= cur + len - 1) {
        s.insert({sum[pos + 1], in[pos].first});
        ++pos;
      } else {
        break;
      }
    }
    while (s.size() > 0) {
      if ((*s.begin()).second < cur) {
        s.erase(s.begin());
      } else {
        break;
      }
    }
    if (s.size() == 0 || (*s.begin()).first + curSum - sum[i + 1] >= 0) {
      printf("%d\n", cur);
      return;
    }
  }
}
int main() {
  solve();
  return 0;
}
