public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNext()) {
            Set<Integer> set = new TreeSet<>();
            int n = sc.nextInt();
            for (int i = 0; i < n; i++) {
                set.add(sc.nextInt());
            }
            int m = sc.nextInt();
            for (int i = 0; i < m; i++) {
                set.add(sc.nextInt());
            }
            ArrayList<Integer> list = new ArrayList<>(set);
            for (int i = 0; i < list.size(); i++) {
                if(i == list.size()-1){
                    System.out.println(list.get(i));
                }else{
                    System.out.print(list.get(i));
                }
            }
        }
    }
}