# -*-coding:utf-8-*-
while True:
try:
input_m1 = int(input())
input_n1 = list(map(int,input().split(" ")))
input_m2 = int(input())
input_n2 = list(map(int,input().split(" ")))
input_nn = input_n1+input_n2
input_nn_s = sorted(set(input_nn),reverse=False)
print("".join(list(map(str,input_nn_s))))
except:
break