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