while True:

try:
    m = int(input())
    list1 = list(map(int, input().split()))
    n = int(input())
    list2 = list(map(int, input().split()))
    
    new_list = list(set(list1 + list2))
    new_list.sort()
    print(''.join(map(str, new_list)))
    
    
except:
    break