# Topic : Two-pointer _ 배열 합치기
# 
# PyPy 3 : 1268ms

N , M = map(int,input().split())

count = max(N,M)

A = list(map(int,input().split()))
B = list(map(int,input().split()))

result = A+B
result.sort()
for r in result:
  print(r,end=" ")