inpstr = input().split()
inpstr01 = input().split()
def keys(ss):
return int(ss)
inpstr01.sort(key=keys)
for i in range(int(inpstr[1])):
print(inpstr01[i], end=" ")
inpstr = input().split()
inpstr01 = input().split()
def keys(ss):
return int(ss)
inpstr01.sort(key=keys)
for i in range(int(inpstr[1])):
print(inpstr01[i], end=" ")