import java.util.Scanner;
public class app {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = 11, m = 11;
        while (n > 10 && m > 10) {
            if (sc.hasNextInt()&&n>10) {
                n = sc.nextInt();
            }
            if (sc.hasNextInt()&&m>10) {
                m = sc.nextInt();
            }
        }
        int min1 = 10, min2 = 10;
        int otv = 0;
        int mass1[] = new int[10];
        int mass2[] = new int[10];
        for (int x = 0; x < n; x++) {
            if (sc.hasNextInt()) {
                mass1[x] = sc.nextInt();
            }
            if (min1 > mass1[x]) {
                min1 = mass1[x];
            }
        }
        for (int x = 0; x < m; x++) {
            if (sc.hasNextInt()) {
                mass2[x] = sc.nextInt();
            }
                if (min2 > mass2[x]) {
                    min2 = mass2[x];
                }
            }
            if (min1 > min2) {
                otv = (min2 * 10) + min1;
                System.out.println(otv);
            }
            if (min1 < min2) {
                otv = (min1 * 10) + min2;
                System.out.println(otv);
            }
            if (min1 == min2) {
                otv = min1;
                System.out.println(otv);
            }
        }
    }