#include <bits/stdc++.h>
using namespace std;
const int N = 2e6 + 20;
const long long MOD2 = 998244353;
const long long MOD = 1e9 + 7;
int n;
long long a, b, c, d, s, len, sg1[4 * N], sg2[4 * N], apr[N], cpr[N];
int t[N], q[N];
vector<int> sxm;
int get(int v) { return lower_bound(sxm.begin(), sxm.end(), v) - sxm.begin(); }
void update(int v, int tl, int tr, int ind, long long val, long long sg[]) {
  if (tl == tr) {
    sg[v] = val;
    return;
  }
  int tm = (tl + tr) / 2;
  if (ind <= tm) {
    update(v + v, tl, tm, ind, val, sg);
  } else {
    update(v + v + 1, tm + 1, tr, ind, val, sg);
  }
  sg[v] = min(sg[v + v], sg[v + v + 1]);
}
long long query(int v, int tl, int tr, int l, int r, long long sg[]) {
  if (l > r) return LLONG_MAX / 2;
  if (tl == l && tr == r) {
    return sg[v];
  }
  int tm = (tl + tr) / 2;
  return min(query(v + v, tl, tm, l, min(r, tm), sg),
             query(v + v + 1, tm + 1, tr, max(l, tm + 1), r, sg));
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
  cin >> n >> a >> b >> c >> d >> s >> len;
  for (int i = (1); i <= (n); ++i) {
    cin >> t[i] >> q[i];
    sxm.push_back(t[i]);
    sxm.push_back(t[i] - len);
    sxm.push_back(t[i] + 1);
    sxm.push_back(t[i] - len + 1);
  }
  sxm.push_back(0);
  sort(sxm.begin(), sxm.end());
  sxm.erase(unique(sxm.begin(), sxm.end()), sxm.end());
  for (int i = 0; i < (4 * (sxm.size() + 1)); ++i) {
    sg1[i] = sg2[i] = LLONG_MAX / 2;
  }
  apr[0] = cpr[0] = s;
  bool bl = true;
  for (int i = (1); i <= (n); ++i) {
    apr[i] = apr[i - 1];
    cpr[i] = cpr[i - 1];
    if (q[i] == 1) {
      apr[i] += a;
      cpr[i] += c;
    } else {
      apr[i] -= b;
      cpr[i] -= d;
    }
    update(1, 0, sxm.size() - 1, get(t[i]), apr[i], sg1);
    update(1, 0, sxm.size() - 1, get(t[i]), cpr[i], sg2);
    if (apr[i] < 0) bl = false;
  }
  for (int i = 0; i < (sxm.size()); ++i) {
    int tv = sxm[i];
    if (tv < 0) continue;
    int ind1 = lower_bound(t + 1, t + n + 1, tv) - t;
    int ind2 = lower_bound(t + 1, t + n + 1, tv + len) - t;
    long long gum1 = apr[ind1 - 1];
    long long mn0 = query(1, 0, sxm.size() - 1, 0, i - 1, sg1);
    long long mn1 =
        query(1, 0, sxm.size() - 1, i, get(tv + len) - 1, sg2) - cpr[ind1 - 1];
    if (mn0 >= 0 && mn1 + gum1 >= 0) {
      cout << tv << endl;
      return 0;
    }
  }
  if (bl) {
    cout << t[n] + 1 << endl;
    return 0;
  }
  cout << -1 << endl;
  return 0;
}
