lixo = list(map(int, raw_input().split()))
lista_01 = list(map(int, raw_input().split()))
lista_02 = list(map(int, raw_input().split()))

minimo_01 = min(lista_01)
minimo_02 = min(lista_02)

if(minimo_01 == minimo_02):
  print(minimo_01)
else:
  print(str(minimo_01)+str(minimo_02))
		 	 						  				  		  	 	  	