import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.stream.Stream;

@SuppressWarnings("ALL")
public class Problem870A {
    public static void main(String[] args) throws IOException  {
        try (BufferedReader z = new BufferedReader(new InputStreamReader(System.in))) {
            z.readLine();
            int min1 = Stream.of(z.readLine().split(" ")).mapToInt(Integer::valueOf).min().getAsInt();
            int min2 = Stream.of(z.readLine().split(" ")).mapToInt(Integer::valueOf).min().getAsInt();
            System.out.println(min1 == min2 ? min1 : min1 < min2 ? min1 * 10 + min2 : min2 * 10 + min1);
        }
    }
}
