input() array = [int(i) for i in input().split()] indexes = {int(i) - 1 for i in input().split()} print(" ".join( str(v + 1) if i in indexes else str(v) for i, v in enumerate(array) ))