while True:
try:
a,b =map(int, input().split())
c =list(map(int, input().split()))
d = sorted(c)
print(' '.join(map(str,d[:b])))
except:
break
while True:
try:
a,b =map(int, input().split())
c =list(map(int, input().split()))
d = sorted(c)
print(' '.join(map(str,d[:b])))
except:
break