def func():
    n = int(input())
    a = list(map(int, input().split()))
    m = int(input())
    b = list(map(int, input().split()))

    aset = set(a)
    bset = set(b)

    cset = aset.union(bset)

    clist = list(cset)
    clist.sort()

    for i in clist:
        print(i, end='')


if __name__ == "__main__":
    func()