while True:
try:
s = list(map(int, input().split()))
num = list(map(int, input().split()))
num.sort()
num = [str(x) for x in num[:s[1]]]
print(' '.join(num))
except:
break
while True:
try:
s = list(map(int, input().split()))
num = list(map(int, input().split()))
num.sort()
num = [str(x) for x in num[:s[1]]]
print(' '.join(num))
except:
break