from itertools import permutations
n, m = map(int, input().split())
nums = [i for i in range(1, n + 1)]
per = permutations(nums, m)
for p in per:
    for num in p:
        print(num, end=' ')
    print()

e2b72f70b494d4b8f57a16f738e6a2f39af2b6f5
<mask token>

<mask token>
for p in per:
    for num in p:
        print(num, end=' ')
    print()

<mask token>
n, m = map(int, input().split())
nums = [i for i in range(1, n + 1)]
per = permutations(nums, m)
for p in per:
    for num in p:
        print(num, end=' ')
    print()

from itertools import permutations
n, m = map(int, input().split())
nums = [i for i in range(1, n + 1)]
per = permutations(nums, m)
for p in per:
    for num in p:
        print(num, end=' ')
    print()
