while True:
    try:
        n1 = int(input())
        a1 = list(map(int,input().split()))
        n2 = int(input())
        a2 = list(map(int,input().split()))
        s = set(a1+a2)
        s = sorted(s)
        for i in s:
            print(i,end='')
    except:
        break