'''
解题思路:
集合合并操作:S = S1.union(S2)
'''
while 1:
    try:

        n1 = int(input())
        L1 = list(map(int,input().strip().split()))
        n2 = int(input())
        L2 = list(map(int,input().strip().split()))

        S1 = set(L1)
        S2 = set(L2)
        S = S1.union(S2)
        #print(S)

        L = sorted(S)
        #print(L)

        t = list(map(str,L))
        print(''.join(t))       

    except:
        break