N, M = map(int, input().split())
arr = list(map(int, input().split()))
arr.sort()
res = []
def dfs(start, cnt):
if cnt == M:
for i in res:
print(i, end=' ')
print()
return
for i in range(start, N):
res.append(arr[i])
dfs(i, cnt + 1)
res.pop()
dfs(0, 0)
백트랙킹 (DFS)