n = int(input())
a = []
t = []
for i in range(n):
    num1,num2 = map(int,input().split())
    a.append(num1)
    t.append(num2)
q = int(input())
x = list(map(int,input().split()))

for j in range(q):
    