#K69772. Print Permutations in Lexicographic Order
Print Permutations in Lexicographic Order
Print Permutations in Lexicographic Order
You are given a positive integer \(n\) and are required to print all the permutations of the numbers from 1 to \(n\) in lexicographic order. Each permutation should be printed on a new line with each number separated by a single space.
For example, if \(n = 3\), the output should be:
1 2 3 1 3 2 2 1 3 2 3 1 3 1 2 3 2 1
inputFormat
The input consists of a single integer \(n\) (1 ≤ \(n\) ≤ 8) provided via standard input.
outputFormat
Print all the permutations of the first \(n\) natural numbers in lexicographic order. Each permutation must appear on a separate line, with the numbers separated by a single space.
## sample1
1