m,n=map(int,input().split()) ans=list(map(int,input().split())) request=list(map(int,input().split())) for i in request: print(ans[i-1])