n, m = map(int, input().split())
ls1 = list(map(int, input().split()))
ls2 = list(map(int, input().split()))
ls = ls1 + ls2
ls.sort()
for i in range(n+m):
print(ls[i], end=" ")
n, m = map(int, input().split())
ls1 = list(map(int, input().split()))
ls2 = list(map(int, input().split()))
ls = ls1 + ls2
ls.sort()
for i in range(n+m):
print(ls[i], end=" ")