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
import sys

def diff(arg, a, b, c, d):
	if arg > 0:
		return c-a
	else:
		return b-d

def partial(ele, box, n, a, b, c, d):
	boxlen = len(box)
	elelen = len(ele)
	res = [0 for i in range(boxlen + 1)]
	elep, boxp = 0, 0
	while elep < elelen:
		if boxp == boxlen:
			res[boxp] += diff(ele[elep], a, b, c, d)
			elep += 1
			continue

		if abs(ele[elep]) < box[boxp]:
			res[boxp] += diff(ele[elep], a, b, c, d)
			elep += 1
		else:
			boxp += 1
	return res

def merge(lst1, lst2):
	pt1, pt2 = 0, 0
	res = []
	back = -1
	while pt1 < len(lst1) or pt2 < len(lst2):
		if pt1 == len(lst1):
			if lst2[pt2] != back:
				res.append(lst2[pt2])
				back = lst2[pt2]
			pt2 += 1
			continue
		if pt2 == len(lst2):
			if lst1[pt1] != back:
				res.append(lst1[pt1])
				back = lst1[pt1]
			pt1 += 1
			continue
		if lst1[pt1] < lst2[pt2]:
			if back != lst1[pt1]:
				res.append(lst1[pt1])
				back = lst1[pt1]
			pt1 += 1
		else:
			if back != lst1[pt1]:
				res.append(lst2[pt2])
				back = lst2[pt2]
			pt2 += 1
	return res

while True:
	try:
		n, a, b, c, d, start, l = tuple(map(int,sys.stdin.readline().split()))
		t = []
		s1, s2 = [], []
		rating = 0
		for i in range(n):
			ti, qi = tuple(map(int,sys.stdin.readline().split()))
			if qi:
				t.append(ti)
				if ti < l:
					rating += c
			else:
				t.append(-ti)
				if ti < l:
					rating -= d
			s1.append(ti)
			s1.append(ti+1)
			if ti - l > 0:
				s2.append(ti - l)
			if ti + 1 - l > 0:
				s2.append(ti + 1 - l)
		s = merge(s1, s2)
		end = []
		for i in range(len(s)):
			end.append(s[i] + l)
		sstep = partial(t,s,n,a,b,c,d)
		estep = partial(t,end,n,0,0,c,d)
		resptr = 0
		while rating < 0 and resptr < len(sstep):
			rating += estep[resptr] - sstep[resptr]
			resptr += 1
		if resptr == len(sstep):
			print(-1)
		else:
			print(s[resptr-1])

	except EOFError:
		break
	else:
		break

try:
	while True:
		n, a, b, c, d, start, l = tuple(map(int,sys.stdin.readline().split()))
		t = []
		s1, s2 = [], []
		rating = 0
		for i in range(n):
			ti, qi = tuple(map(int,sys.stdin.readline().split()))
			if qi:
				t.append(ti)
				if ti < l:
					rating += c
			else:
				t.append(-ti)
				if ti < l:
					rating -= d
			s1.append(ti)
			s1.append(ti+1)
			if ti - l > 0:
				s2.append(ti - l)
			if ti + 1 - l > 0:
				s2.append(ti + 1 - l)
		s = merge(s1, s2)
		end = []
		for i in range(len(s)):
			end.append(s[i] + l)
		sstep = partial(t,s,n,a,b,c,d)
		estep = partial(t,end,n,0,0,c,d)
		resptr = 0
		while rating < 0 and resptr < len(sstep):
			rating += estep[resptr] - sstep[resptr]
			resptr += 1
		if resptr == len(sstep):
			print(-1)
		else:
			print(s[resptr-1])

except EOFError:
	pass