https://www.acmicpc.net/problem/15650
n, m = map(int, input().split())
ans = []
arr = [i for i in range(1, n+1)]
def sol(a):
if len(ans) == m:
print(*ans, end=" ")
print()
for i in range(a, n):
ans.append(arr[i])
sol(i+1)
ans.pop()
sol(0)