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 math
def bifind(x, pivot):
#find the first number's subscript in x
#s.t. the number is bigger or queal than pivot
    l, r = 0, len(x)
    #bi find in [l,r)
    while (r-l) > 1:# it must come to 1 before come to 0
        mid = int((l+r)/2)
        if x[mid] >= pivot:# if true
            r = mid
        else:
            l = mid
    if (x[l] < pivot)and(x[r] >= pivot):
        return r
    if (x[l] >= pivot)and(x[r] >= pivot):
        return l
    return -1
        

def f(i,j):#ST[i,j]表示[i,i+2^j-1]这个区间内的最小值
    if ST[i][j] != -15289758923 :return ST[i][j]
    if j == 0 :
        ST[i][j] = total[i]
        return ST[i][j]
    ans = min(f(i,j-1),f(i+2**(j-1),j-1))
    ST[i][j] = ans
    return ans

def g(x,y):
    i = min(x,y)
    j = max(x,y)
    k = int(math.log(j-i+1)/math.log(2))
    return min(f(i,k), f(j-2**k+1,k))
#return the min number in total[i,j]

n, a, b, c, d, start, l = map(int, input().split())
photo = []
fashion = []
t = []
q = []
for i in range(n):
    x, y = map(int,input().split())
    t.append(x)
    q.append(y)

count = [start]
#count[i] = the rating of first i event happend without inflence
deadline = 12345677801234
for i in range(n):
    if q[i]: count.append(count[i] + a)
    else : count.append(count[i] - b)
    if count[i+1] < 0:
        deadline = t[i]
        break
#must start talk show before t[i]

if q[0]:
    total = [c]
else:
    total = [-d]
#total[i] = the rating after i+1 event happend with inflence
for i in range(1, n):
    if q[i]: total.append(total[i-1] + c)
    else : total.append(total[i-1] - d)

ST = []

for i in range(312345):
    ST.append([])
    for j in range(20):
        ST[i].append(-15289758923)
        
for i in range(n):
    ST[i][0] = total[i]

t.append(10000000000)
tpoint = [0]
for i in range(n):#all possible answer
    tpoint.append(t[i]+1)
    tpoint.append(t[i]-l+1)

ans = 1234567881234
for i in tpoint:
    if i >= deadline : continue
    if i < 0 : continue
    x, y = bifind(t, i), bifind(t, i+l)
    #print(i,x,y)
    #the influence is last in [x,y) in t
    init = count[x]
    if x == y:
        if init >=0:
            ans = min(i, ans)
        continue
    if x : xiu = total[x-1]
    else : xiu = 0
    if g(x,y-1) - xiu + init >= 0:
        ans = min(i, ans)

if ans == 1234567881234: print(-1)
else : print(ans)













