import java.util.Iterator;
import java.util.Scanner;
import java.util.Set;
import java.util.TreeSet;
public class CombineArray {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int first = scan.nextInt();
		int []fArray = new int[first];
		for (int i = 0; i < fArray.length; i++) {
			fArray[i] = scan.nextInt();
		}
		int second = scan.nextInt();
		int []sArray = new int[second];
		for (int j = 0; j < sArray.length; j++) {
			sArray[j] = scan.nextInt();
		}
		 getCombineArray(fArray,sArray);
	}

	private static void getCombineArray(int[] fArray, int[] sArray) {
		Set<Integer> set = new TreeSet<Integer>();
		for (int i = 0; i < fArray.length; i++) {
			set.add(fArray[i]);
		}
		
		for (int i = 0; i < sArray.length; i++) {
			set.add(sArray[i]);
		}
		
		Iterator<Integer> it = set.iterator();
		while (it.hasNext()) {
			System.out.print(it.next());
		}
	}

	
}