import sys
n = int(input())
w = [int(i.strip()) for i in sys.stdin.readlines()]
w = set(w)
w = sorted(list(w))
for i in w:
print(i)
n = int(input())
w = [int(i.strip()) for i in sys.stdin.readlines()]
w = set(w)
w = sorted(list(w))
for i in w:
print(i)