while True:
try:
num1 = int(input())
arr1 = list(map(int, input().split()))
num2 = int(input())
arr2 = list(map(int, input().split()))
arr = arr1+arr2
list_arr = sorted(set(arr))
res = ''.join(list(map(str,list_arr)))
print(res)
except:
break