tmp1 = list(map(int, input().split(" ")))

num = [0 for i in range(10**5)]

for i in range(tmp1[0]):

    tmp = list(map(int, input().split(" ")))

    num[tmp[0]-1] += tmp[1]

tmp = 0

i = 0

while tmp < tmp1[1]:

    tmp = tmp + num[i]

    if tmp >= tmp1[1]:

        print((i+1))

    i = i + 1
tmp = input().split(" ")

K = int(tmp[1])

 

num = [0 for i in range(10**5)]

for i in range(int(tmp[0])):

    tmp = input().split(" ")

    num[int(tmp[0])-1] += int(tmp[1])

    

tmp = 0

i = 0

while tmp < K:

    tmp = tmp + num[i]

    if tmp >= K:

        print((i+1))

    i = i + 1
tmp1 = list(map(int, input().split(" ")))
num = [0 for i in range(10**5)]
for i in range(tmp1[0]):
    tmp = list(map(int, input().split(" ")))
    num[tmp[0] - 1] += tmp[1]
tmp = 0
i = 0
while tmp < tmp1[1]:
    tmp = tmp + num[i]
    if tmp >= tmp1[1]:
        print((i + 1))
    i = i + 1

tmp = input().split(" ")
K = int(tmp[1])
num = [0 for i in range(10**5)]
for i in range(int(tmp[0])):
    tmp = input().split(" ")
    num[int(tmp[0]) - 1] += int(tmp[1])
tmp = 0
i = 0
while tmp < K:
    tmp = tmp + num[i]
    if tmp >= K:
        print((i + 1))
    i = i + 1

-tmp1 = list(map(int, input().split(" "))) +tmp = input().split(" ") +K = int(tmp[1]) -for i in range(tmp1[0]): -    tmp = list(map(int, input().split(" "))) -    num[tmp[0] - 1] += tmp[1] +for i in range(int(tmp[0])): +    tmp = input().split(" ") +    num[int(tmp[0]) - 1] += int(tmp[1]) -while tmp < tmp1[1]: +while tmp < K: -    if tmp >= tmp1[1]: +    if tmp >= K: