l = list(input().split())
l2 = list(input().split())
l3 = list(input().split())
l2.sort()
l3.sort()
i = 0
i2 = 0
outatr = 1
while i < len(l2) and outatr == 1:
    while i2 < len(l3) and outatr == 1:
        if l2[i] == l3[i2]:
            print(l2[i])
            outatr = 0
            break
        i2 += 1
    i += 1
if outatr != 0:
    print(l2[0] + l3[0])