while True:
    try:
        List1Count = int(input())
        List1 = input().split()
        if len(List1) != List1Count:
            print("数组1的长度和预期不符,请重新输入")
            break
            
        List2Count = int(input())
        List2 = input().split()
        if len(List2) != List2Count:
            print("数组2的长度和预期不符,请重新输入")
            break
            
        NewList = list(set(List1+List2))    # 利用集合set把数组元素去重,然后再转换成列表
        #print(NewList)
        NewList.sort(key=int)    # list.sort()也有key=int/str和reverse=true/false的用法,默认是ASSIC排序
        print("".join(NewList))
    except:
        break