#abc288g. [abc288_g]3^N Minesweeper
[abc288_g]3^N Minesweeper
Problem Statement
There is zero or one bomb at each of positions .
Let us say that positions and are neighboring each other if and only if the following condition is satisfied for every .
- Let and be the -th lowest digits of and in ternary representation, respectively. Then, .
It is known that there are exactly bombs in total at the positions neighboring position . Print a placement of bombs consistent with this information.
Constraints
- There is a placement of bombs consistent with .
- All values in the input are integers.
Input
The input is given from Standard Input in the following format:
Output
Print with spaces in between, where if position has no bomb and if position has a bomb.
Sample Input 1
1
0 1 1
Sample Output 1
0 0 1
Position is neighboring positions and , which have bombs in total.
Position is neighboring positions , , and , which have bomb in total.
Position is neighboring positions and , which have bombs in total.
If there is a bomb at only position , all conditions above are satisfied, so this placement is correct.
Sample Input 2
2
2 3 2 4 5 3 3 4 2
Sample Output 2
0 1 0 1 0 1 1 1 0
Sample Input 3
2
0 0 0 0 0 0 0 0 0
Sample Output 3
0 0 0 0 0 0 0 0 0