def dfs1(n, m):
if len(s) == m:
print(" ".join(map(str, s)))
return
for i in range(1, n+1):
if i not in s:
s.append(i)
dfs1(n, m)
s.pop()
def dfs2(n, m, x):
if len(s) == m:
print(" ".join(map(str, s)))
return
for i in range(x, n+1):
if i not in s:
s.append(i)
dfs2(n, m, i+1)
s.pop()
def dfs3(n, m):
if len(s) == m:
print(" ".join(map(str, s)))
return
for i in range(1, n+1):
s.append(i)
dfs3(n, m)
s.pop()
def dfs4(n, m, x):
if len(s) == m:
print(" ".join(map(str, s)))
return
for i in range(x, n+1):
s.append(i)
dfs4(n, m, i)
s.pop()
n, m = [int(v) for v in input().split()]
s = []
# dfs1(n, m)
# dfs2(n, m, 1)
# dfs3(n,m)
dfs4(n,m, 1)
백트래킹 맛보기 문제들!!