import sys
N, M = map(int, input().split(' '))
tmp = list(map(int, sys.stdin.readline()[:-1].split(' ')))
tmp.sort()
result = []
def dfs(idx_flag):
if len(result) == M:
print(" ".join(map(str, result)))
return
flag = 0
for i in range(idx_flag, N):
if flag != tmp[i]:
result.append(tmp[i])
flag = tmp[i]
dfs(i)
result.pop()
dfs(0)