K = 20 f = lambda L: int("".join([bin(a + (1 << K))[3:] for a in L]), 2) N, Q = map(int, input().split()) A = [int(a) for a in input().split()] R = [int(a) for a in input().split()] C = [0] * N for r in R: C[r] += 1 S = bin(f(A) * f(C[::-1]) % ((1 << K * N) - 1) + (1 << K * N))[3:] print(" ".join([str(int(S[i*K:(i+1)*K], 2)) for i in range(N)]))