m = int(input())
costs = list(map(int, input().split()))

n, e = map(int, input().split())

belt = [0]*(n+1)

chef_time = 0
chef_ind = 0

for _ in range(e):
    t, x = map(int, input().split())
    while chef_time < t:
        if not belt[(-chef_time)%(n+1)]:
            belt[(-chef_time)%(n+1)] = costs[chef_ind%m]
            chef_ind += 1
        chef_time += 1
    assert belt[(x-t)%(n+1)] != 0
    belt[(x-t)%(n+1)] = 0

import sys
sys.exit(42)
