n, m = map(int, input().split())
path = [0] * (m + 1) # 保存路径
st = [0] * (n + 1) #
def dfs(u):
global st
if u > m:
for i in range(1, m + 1):
print(path[i], end=' ')
print()
st = [0] * (n + 1)
return
for i in range(1, n + 1):
if not st[i] and i >= path[u-1]:
path[u] = i
st[i] = 1
dfs(u + 1)
st[i] = 0
dfs(1)