#include <bits/stdc++.h>
using namespace std;
const long long maxN = 300010;
struct event {
  long long t, q;
};
event e[maxN];
long long sum[maxN];
long long n, a, b, c, d, s, k;
signed main() {
  ios::sync_with_stdio(false);
  cin >> n >> a >> b >> c >> d >> s >> k;
  long long in[] = {-d, c};
  long long out[] = {-b, a};
  for (long long i = 0; i < n; i++) cin >> e[i].t >> e[i].q;
  for (long long i = 0; i < n; i++) sum[i + 1] = sum[i] + in[e[i].q];
  set<pair<long long, long long>> order;
  order.insert({sum[0], 0});
  long long i = 0, j = 0;
  long long last = 0;
  while (i <= n) {
    while (j < n && e[j].t < last + k) {
      j = j + 1;
      order.insert({sum[j], j});
    }
    long long val = order.begin()->first - sum[i];
    if (0 <= s + val) {
      cout << last << endl;
      break;
    }
    last = e[i].t + 1;
    s += out[e[i++].q];
    order.erase({sum[i], i});
    if (s < 0) {
      cout << -1 << endl;
      break;
    }
  }
  return 0;
}
