A sequence of numbers is d-balanced if the absolute value of the difference between any two consecutive numbers is at most d. Formally (x1, x2, … , xn) is d-balanced if for all 1 ≤ i < n it holds that | xi − xi+1 | ≤ d.
Write a program that, given an integer n≥ 1 and an integer d ≥ 0, writes all d-balanced sequences that can be obtained by reordering the sequence (1, 2, … , n).
Input
The input consists of an integer n ≥ 1 followed by another integer d ≥ 0.
Output
Write all d-balanced sequences that can be obtained by reordering the sequence (1, 2, … , n). 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)