import java.io.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;

public class Main {

    public static void main(String[] args) throws IOException{
    BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        reader.readLine();
        ArrayList<String> firstArl = new ArrayList<String>();
        ArrayList<String> secondArl = new ArrayList<String>();
        for (String i:reader.readLine().split(" ")) {
            firstArl.add(i);

        }
        for (String i:reader.readLine().split(" ")) {
            secondArl.add(i);
        }
        Collections.sort(firstArl);
        Collections.sort(secondArl);
        if(Integer.parseInt(firstArl.get(0))==Integer.parseInt(secondArl.get(0)))
        {
            System.out.println(firstArl.get(0));
        }
        else if(Integer.parseInt(firstArl.get(0))<Integer.parseInt(secondArl.get(0))) {
            System.out.println(firstArl.get(0) + secondArl.get(0));
        }
        else if(Integer.parseInt(firstArl.get(0))>Integer.parseInt(secondArl.get(0))) {
            System.out.println(secondArl.get(0) + firstArl.get(0));
        }


    }
}