while True:
    try:
        m = int(input())
        list1 = list(map(int,input().split()))
        n = int(input())
        list2 = list(map(int,input().split()))
        total_list = list1 + list2
        sorted_list=sorted(total_list)
        new_list=[]
        for num in sorted_list:
            if num not in new_list:
                new_list.append(num)
        print(''.join(map(str,new_list)))
    except:
        break