There are two main kinds of events in the life of top-model: fashion shows and photo shoots. Participating in any of these events affects the rating of appropriate top-model. After each photo shoot model's rating increases by *a* and after each fashion show decreases by *b* (designers do too many experiments nowadays). Moreover, sometimes top-models participates in talk shows. After participating in talk show model becomes more popular and increasing of her rating after photo shoots become *c* and decreasing of her rating after fashion show becomes *d*.

Izabella wants to participate in a talk show, but she wants to do it in such a way that her rating will never become negative. Help her to find a suitable moment for participating in the talk show. 

Let's assume that model's career begins in moment 0. At that moment Izabella's rating was equal to *start*. If talk show happens in moment *t* if will affect all events in model's life in interval of time [*t*..*t* + *len*) (including *t* and not including *t* + *len*), where *len* is duration of influence.

Izabella wants to participate in a talk show, but she wants to do it in such a way that her rating will not become become negative before talk show or during period of influence of talk show. Help her to find a suitable moment for participating in the talk show.
In first line there are 7 positive integers *n*, *a*, *b*, *c*, *d*, *start*, *len* (1 ≤ *n* ≤ 3·10<sup class="upper-index">5</sup>, 0 ≤ *start* ≤ 10<sup class="upper-index">9</sup>, 1 ≤ *a*, *b*, *c*, *d*, *len* ≤ 10<sup class="upper-index">9</sup>), where *n* is a number of fashion shows and photo shoots, *a*, *b*, *c* and *d* are rating changes described above, *start* is an initial rating of model and *len* is a duration of influence of talk show.

In next *n* lines descriptions of events are given. Each of those lines contains two integers *t*<sub class="lower-index">*i*</sub> and *q*<sub class="lower-index">*i*</sub> (1 ≤ *t*<sub class="lower-index">*i*</sub> ≤ 10<sup class="upper-index">9</sup>, 0 ≤ *q* ≤ 1) — moment, in which event happens and type of this event. Type 0 corresponds to the fashion show and type 1 — to photo shoot. 

Events are given in order of increasing *t*<sub class="lower-index">*i*</sub>, all *t*<sub class="lower-index">*i*</sub> are different.
none
5 1 1 1 4 0 5
1 1
2 1
3 1
4 0
5 0
6
1 1 2 1 2 1 2
1 0
-1
10 1 1 1 2 0 10
1 1
2 1
3 0
4 0
5 1
6 1
7 1
8 1
9 1
10 1
5
//
// Created by shhuan on 2017/11/14.
//

#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <map>
#include <set>
#include <queue>
#include <ostream>
#include <istream>
#include <typeinfo>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <limits>
#include <fstream>
#include <array>
#include <list>
#include <bitset>
#include <functional>
#include <random>
using namespace std;


#define pb push_back
#define pp pop_back
#define pf push_front
#define ppf pop_front
#define _ inline
#define fst first
#define sec second
#define ins insert
#define ers erase
#define mp make_pair
#define mt make_tuple
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz size
#define rsz resize
#define pw2(x) (1<<(x))
#define chcpy(Vec) copy(Vec.begin(), Vec.end(), ostream_iterator<char>(cout))
#define intcpy(Vec) copy(Vec.begin(), Vec.end(), ostream_iterator<int>(cout, " "))
#define elif else if
#define uset unordered_set
#define umap uorderd_map
#define rep(i, l, r) for(int i=l; i<r; i++)
#define rep2(i, l, r) for(int i=l; i<=r; i++)
#define rrep(i, l, r) for(int i=l; i>r; i--)
#define rrep2(i, l, r) for(int i=l; i>=r; i--)


typedef long L;
typedef long long LL;
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef double LD;
typedef unsigned int UINT;
typedef unsigned long long ULL;
typedef unsigned long UL;
typedef vector<vector<int>> VVI;
typedef vector<vector<UINT>> VVUINT;
typedef vector<vector<L>> VVL;
typedef vector<vector<LL>> VVLL;
typedef vector<int> VI;
typedef vector<long> VL;
typedef vector<LL> VLL;
typedef vector<PII> VPII;
typedef vector<PLL> VPLL;
typedef vector<LD> VLD;
typedef vector<bool> VB;
typedef tuple<LL, LL, LL> TLLL;
typedef tuple<int, int, int> TIII;
typedef set<int> SI;
typedef set<long> SL;
typedef set<LL> SLL;
typedef multiset<int> MSI;
typedef multiset<long> MSL;
typedef multiset<LL> MSLL;


const int INF = 1000000007;
const double eps = 0.000001;


const L MOD = 1000000000 + 7;
const int M = 1000000 + 6;
const int MAXN = 1000000;

PII A[MAXN];
int pre1[MAXN], pre2[MAXN];

int main() {
	int N, a, b, c, d, start, l;
	cin >> N >> a >> b >> c >> d >> start >> l;

	int t, q;
	rep2(i, 1, N) {
		cin >> t >> q;
		A[i] = mp(t, q);
	}
	A[0] = mp(-1, -1);

	pre1[0] = pre2[0] = start;

	rep2(i, 1, N) {
		if (A[i].second == 1) {
			pre1[i] = pre1[i - 1] + a;
			pre2[i] = pre2[i - 1] + c;
		} else {
			pre1[i] = pre1[i - 1] - b;
			pre2[i] = pre2[i - 1] - d;
		}
	}

	MSL se;
	int uk = 1;

	rep2(i, 0, N) {
		if (pre1[i] < 0) {
			cout << -1 << endl;
			exit(0);
		}
		if (i) {
			se.erase(se.find(pre2[i]));
		}
		int t = A[i].first + 1;
		while (uk <= N && A[uk].second < t + l) {
			se.insert(pre2[uk]);
			uk++;
		}

		if (se.empty()) {
			cout << t << endl;
			exit(0);
		}

		long v = *(se.begin());
		v += pre1[i] - pre2[i];
		if (v >= 0) {
			cout << t << endl;
			exit(0);
		}

	}

}