import sys
sys.setrecursionlimit((10**5))
N, M = map(int, input().split())
elem = list(map(int, input().split()))
elem.sort()
check = [0] * N
ans = [0] * N
## depth 깊이
def recur(depth, cnt):
if cnt == M:
print(' '.join(map(str, ans[:M])))
return
if depth >= N:
return
ans[cnt] = elem[depth]
recur(depth+1, cnt+1)
ans[cnt] = 0
recur(depth+1, cnt)
recur(0, 0)