#include <bits/stdc++.h>   using namespace std;   long long n, a, b, c, d, s, len;   vector<long long> z, t, v[2];   map<long long, int> ma;   int main() {     ios_base::sync_with_stdio(false);     cin >> n >> a >> b >> c >> d >> s >> len;     t.assign(n + 1, -1);     v[0].assign(n + 1, s);     v[1].assign(n + 1, s);     for (int i = 0; i < n; ++i) {       int q;       cin >> t[i + 1] >> q;       v[0][i + 1] = v[0][i] + (q ? a : -b);       v[1][i + 1] = v[1][i] + (q ? c : -d);     }     int lim = 0;     ++ma[v[1][0]];     for (int i = 0; i < n + 1; ++i) {       if (v[0][i] < 0) break;       if (!(--ma[v[1][i]])) ma.erase(v[1][i]);       int be = t[i] + 1;       while (lim < n + 1 && t[lim] < be + len) {         ++ma[v[1][lim]];         ++lim;       }       if (i + 1 == lim || v[0][i] - v[1][i] + ma.begin()->first >= 0) {         cout << be << endl;         return 0;       }     }     cout << -1 << endl;     return 0;   }   