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