n,a=map(int,input().split()) x=list(map(int,input().split())) t=int(input()) q=[tuple(map(int,input().split())) for i in range(t)] for i in range(n): a=-1 for j in reversed(range(t)): if q[j][0]<=x[i]<=q[j][1]: print(j+1) break print(a)