total_num=input()
num=input().split(" ")
nums=list(map(int,num))
insert_num=input()
nums.append(int(insert_num))
nums.sort()
for i in range(len(nums)):
print(nums[i],end=" ")
print()
total_num=input()
num=input().split(" ")
nums=list(map(int,num))
insert_num=input()
nums.append(int(insert_num))
nums.sort()
for i in range(len(nums)):
print(nums[i],end=" ")
print()