import sys #sys.stdin=open("input.txt", "rt") M, N = map(int,input().split()) s = [] def dfs(): if len(s)==N : print(' '.join(map(str,s))) return for i in range(1,M+1): if i not in s: s.append(i) dfs() s.pop() dfs()