#P1118. FJ's Sum Puzzle

    ID: 13245 Type: Default 1000ms 256MiB

FJ's Sum Puzzle

FJ's Sum Puzzle

FJ and his cows are playing an interesting mental game with numbers. Initially, the numbers from 11 to NN (with 1N101 \le N \le 10) are arranged in some order. Then, adjacent numbers are repeatedly summed to form a new list until only one number is left. Formally, if the initial sequence is a1,a2,,aNa_1, a_2, \dots, a_N, then the final number is given by:

$$\text{Final} = \sum_{i=1}^{N} \binom{N-1}{i-1} a_i. $$

The cows now challenge FJ: given the final number and NN, determine the original permutation of numbers 1,2,,N1, 2, \dots, N that produces the given final number. It is guaranteed that a unique solution exists.

inputFormat

The input consists of a single line containing two integers separated by a space: NN (the number of numbers) and FF (the final total after the summing process).

outputFormat

Output the unique permutation of numbers from 11 to NN (separated by spaces) that produces the final sum FF when the described process is applied.

sample

4 16
3 1 2 4