while True: try: n, nums1 = int(input()), list(map(int, input().split())) m, nums2 = int(input()), list(map(int, input().split())) res = '' visited = set() nums1 = sorted(nums1) nums2 = sorted(nums2) i = 0 j = 0 import sys x = sys.maxsize + 1 while i < n or j < m: n1 = nums1[i] if i < n else x n2 = nums2[j] if j < m else x if n1 <= n2: if n1 not in visited: visited.add(n1) res += str(n1) i += 1 elif n2 < n1: if n2 not in visited: visited.add(n2) res += str(n2) j += 1 print(res) except: break