sizeFirst, sizeSecond = map(int, raw_input().split())
first = raw_input().split();
second = raw_input().split();

def procuraMenor(array):
	menor = int(array[0])
	for i in array:
		if int(i) < menor:
			menor = int(i)
	return menor

print "%i%i" % (procuraMenor(first), procuraMenor(second))
