n = int(input())
nums = list(map(int, input().split()))
if n < 3:
print(nums)
exit()
i = 0
for j in range(1, len(nums)):
if nums[j] != nums[i]:
i += 1
nums[j], nums[i] = nums[i], nums[j]
print(*nums)
n = int(input())
nums = list(map(int, input().split()))
if n < 3:
print(nums)
exit()
i = 0
for j in range(1, len(nums)):
if nums[j] != nums[i]:
i += 1
nums[j], nums[i] = nums[i], nums[j]
print(*nums)