import bisect N,A=map(int,input().split()) X=[int(x) for x in input().split()] Y=sorted(X) T=int(input()) ans=[-1]*N for t in range(T): L,R=map(int,input().split()) lower=bisect.bisect_left(Y,L) upper=bisect.bisect_right(Y,R) ans[lower:upper]=[t+1]*(upper-lower) for i in range(N): print(ans[bisect.bisect_left(Y,X[i])])