while True:
    try:
        num_1 = int(input())
        a = list(map(int,input().split()))
        num_2 = int(input())
        b = list(map(int,input().split()))
        a = set(a) #变为集合(自动去重)
        b = set(b) #变为集合
        c = a | b #求并集,交集为&
        c = list(c)
        c.sort() #排序,默认从小到大
        for i in range(len(c)): #按要求输出
            c[i] = str(c[i])
        print(''.join(c))
    except:
        break