白駿15649号:NとM(1)


n,m = map(int,input().split())
sol = []

def recur(cur):
    if cur == m :
        for i in sol:
            print(i, end=' ')
        print()
        return
    for i in range(1,n+1):
        if i not in sol:
            sol.append(i)
            recur(cur+1)
            sol.pop()
recur(0)