(lambda _, a, b: print(*(j + 1 if i + 1 in b else j for i, j in enumerate(a))))(input(), map(int, input().split()), set(map(int, input().split())))