Generate all permutations
Given n integers from 1 to n, arrange them in a row and output all possible permutations after random shuffling.
Input Format
An integer n.
Output Format
Output all possible permutations in ascending lexicographical order, one per line.
- Adjacent numbers in the same line should be separated by a space.
 - Different permutations are sorted in ascending order according to the lexicographical order.
 
Constraints
1 ≤ n ≤ 9
Sample Input
3
Sample Output
1 2 3
1 3 2
2 1 3
2 3 1
3 1 2
3 2 1
Comments