while True:
try:
n1, nums1 = int(input()), list(map(int, input().split()))
n2, nums2 = int(input()), list(map(int, input().split()))
res = list(set(nums1) | set(nums2))
for i in sorted(res):
print(i, end='')
print()
except:
break