eolymp
bolt
Try our new interface for solving problems
Problems

Permutations of n by k

Permutations of n by k

For a given natural number $n$, derive all permutations of integers from $1$ to $n$ to $k$ numbers in lexicographic order.

\InputFile

Two natural numbers $n$ and $k$$(1 ≤ k ≤ n ≤ 8$).

\OutputFile

Derive all permutations of integers from $1$ to $n$ to $k$ numbers in lexicographic order. Each permutation should be displayed on a separate line.

Time limit 1 second
Memory limit 64 MiB
Input example #1
3 2
Output example #1
1 2 
1 3 
2 1 
2 3 
3 1 
3 2 
Source Абетка програмування