import java.util.*;
import java.util.stream.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
while (sc.hasNextInt()) {
int a = Integer.parseInt(sc.nextLine());
String str1 = sc.nextLine();
int b = Integer.parseInt(sc.nextLine());
String str2 = sc.nextLine();
// 将两个数组元素合并为一个set集合,set天然去重
String[] split1 = str1.split(" ");
Set<Integer> set = new HashSet<>();
for (String s : split1) {
set.add(Integer.parseInt(s));
}
String[] split2 = str2.split(" ");
for (String s : split2) {
set.add(Integer.parseInt(s));
}
// 利用stream流排序
List<Integer> list = set.stream().sorted().collect(Collectors.toList());
list.forEach(s -> System.out.print(s));
}
}
}