Baltic Olympiad in Informatics: 2004 Day 1, Problem 2
You are given an equal arm scale, a set of weight pieces, and an object. The pieces are of weight , i.e. the weight of each piece is a power of , and for each integer there is exactly one piece of weight . The object's weight is , where is a positive integer. Your task is to put the object on the left scale pan and to put some pieces on one or both scale pans, so that the scale is in balance.
Constraints
Input Specification
The first line of the input contains one integer .
Output Specification
Your output should consist of two lines.
The first line should contain information about pieces put on the left scale pan. The first number must be a non-negative integer - the number of pieces put on the left scale pan followed by weights of pieces in increasing order. Numbers must be separated by single spaces.
The second line must contain information about pieces put on the right scale pan with the same format as the first line.
Sample Input 1
42
Sample Output 1
3 3 9 27
1 81
Sample Input 2
30
Sample Output 2
0
2 3 27
Comments