n = int(input())
a1 = list(map(int, input().split(" ")))

m = int(input())
a2 = list(map(int, input().split(" ")))

# 先过滤重复元素
ans = []
for num in a1 + a2:
    if num not in ans:
        ans.append(num)

# 排序后按规定输出
s = ""
for num in sorted(ans):
    s += str(num)
print(s)