A sequence of numbers has a well if it contains three consecutive numbers such that that the endpoints add up more than twice the one in the middle.
Formally, has a well if it exists at least an with such that .
Write a program that, given an integer , writes all sequences with no well that can be obtained by reordering the sequence .
The input consists of an integer .
Write all sequences with no well that can be obtained by reordering the sequence . You can write the sequences in any order.
Input
3
Output
(1,2,3) (1,3,2) (2,3,1) (3,2,1)
Input
2
Output
(1,2) (2,1)
Input
4
Output
(1,2,3,4) (1,3,4,2) (1,4,3,2) (2,3,4,1) (2,4,3,1) (4,3,2,1)
Input
1
Output
(1)