import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int a = in.nextInt();
        Set<Integer> ts = new TreeSet<>();
        for(int i = 0; i<a; i++){
            ts.add(in.nextInt());
        }
        int b = in.nextInt();
        for(int i = 0; i<b; i++){
            ts.add(in.nextInt());
        }
        for(Integer i : ts){
            System.out.print(i);
        }
    }
}