n,q=map(int,input().split())
P=list(map(int,input().split()))
S=list(map(int,input().split()))
V=list(map(int,input().split()))
f=P.count(1)
for v in V:
    if v==1:
        print(0,end=" ")
    elif v==2:
        print(1,end=" ")
    elif f==1:
        print(v-1,end=" ")
    else:
        print(v-1,end=" ")
    
