import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner in = new Scanner(System.in);
        while(in.hasNext()){
            Set<Integer> set = new HashSet<>();
            int n1 = in.nextInt();
            for (int i = 0; i < n1; i++){
                set.add(in.nextInt());
            }
            int n2 = in.nextInt();
            for (int i = 0; i < n2; i++){
                set.add(in.nextInt());
            }
            int n3 = set.size();
            int[] arr = new int[n3];
            int k = 0;
            for (int i : set){
                arr[k] = i;
                k++;
            }
            Arrays.sort(arr);
            String res = "";
            for (int i = 0; i < n3; i++){
                res += arr[i];
            }
            System.out.println(res);
        }
    }
}