while True:
try:
n, k = map(int, input().split())
nums = map(int, input().split())
for n in sorted(nums)[:k]:
print(n, end=' ')
print()
except:
break
while True:
try:
n, k = map(int, input().split())
nums = map(int, input().split())
for n in sorted(nums)[:k]:
print(n, end=' ')
print()
except:
break