# 将两个整型数组按照升序合并
#并且过滤掉重复数组元素。set(obj)
# 输出时相邻两数之间没有空格
while True:
try:
m1_cn = int(input())
m1 = input().split()
m2_cn = int(input())
m2 = input().split()
m = m1 + m2
m = set(m)
n = []
for i in m:
n.append(int(i))
n = sorted(n)
for i in n:
print(i,end='')
except:
break