A sequence of numbers is -balanced if the absolute value of the difference between any two consecutive numbers is at most . Formally is -balanced if for all it holds that .
Write a program that, given an integer and an integer , writes all -balanced sequences that can be obtained by reordering the sequence .
The input consists of an integer followed by another integer .
Write all -balanced sequences that can be obtained by reordering the sequence . You can write the sequences in any order.
Input
3 1
Output
(1,2,3) (3,2,1)
Input
4 2
Output
(1,2,3,4) (1,2,4,3) (1,3,2,4) (1,3,4,2) (2,1,3,4) (2,4,3,1) (3,1,2,4) (3,4,2,1) (4,2,1,3) (4,2,3,1) (4,3,1,2) (4,3,2,1)
Input
1 0
Output
(1)