while 1:
    try:
        s0,s1,s3,s2 = input(), input().split(), input(), input().split()
        s = map(str,sorted(map(int, set(s1+s2))))
        print(''.join(s))
    except:
        break