TWINGIFT2
It's Andreas' and Vaso's birthdays again*, and this time it's their grandfather's turn to get them gifts. The grandfather knows that Vaso plays chess and loves the chessboard he has in his living room, with its marble pieces. He decides she would be very happy if he gave her this as a gift. Additionally, both children admire their grandfather's coin collection, which gives him the idea for Andreas' gift: he will give him some of his coins. The only difficulty remaining for the grandfather is how to ensure that the gifts for both children are of equal value...
The grandfather calculates that the chessboard is worth euros. His coin collection includes coins whose values are powers of , but there is only one coin of each type - that is, he has one coin worth euro, one worth euros, one worth euros, one worth euros, etc. Fortunately, his collection is very large (and the grandfather very wealthy) - you can assume that there are infinitely many coins in his collection, one for each power of .
Trying to find which coins he should give to Andreas so that their values sum to euros, the grandfather sees that this is not always possible (that is, for all values of ). He considers that he may complement Vaso's gift with some coins, so that the total value of both children's gifts is equal, and as he is good at mathematics, he proves that this is always possible.
Help the grandfather find which coins he should give to Andreas and which to Vaso (along with the chessboard), so that the total value of both children's gifts is equal.
Input:
The first line of the input will contain a positive integer : the number of queries your program must answer. Each of the next lines will correspond to a query and will contain a positive integer : the value of the chessboard.
Output:
The output must contain lines, each one corresponding to the answer to the respective query from the input. Each line should first contain the values of the coins that Vaso will take, in ascending order, followed by the character '#', and then the values of the coins that Andreas will take, also in ascending order. All values should be separated in pairs by a single space. If there are multiple correct answers for any query, you can output any of them.
Constraints:
- Time Limit: sec.
- Memory Limit: MB.
- For test cases with a total value of , it will be .
Example of Input - Output:
input:
3
42
30
17
output:
3 9 27 # 81
# 3 27
1 9 # 27
Explanation of the example:
In the first question, Vaso will take the chessboard () and coins of value , , and , while Andreas will take a coin of - . In the second question, Vaso will only take the chessboard - verifying that . In the third question, it holds that .
*The solution to this problem is not related to the solution of the twingift problem from phase B'- only the story has similarities.
Comments