Balanced ternary is a numeral system based on three values: $-1, 0, 1$. This system was notably used by Russian scientists in early computer systems and has applications in optical computing. Recently, it has been explored anew in the context of large language models, as detailed in the paper The Era of 1-bit LLMs: All Large Language Models are in 1.58 Bits.
Formally, for a balanced ternary number $(a_ma_{m-1}\cdots a_0)_{\bar 3}$ where $a_0,\cdots,a_m\in\set{-1,0,1}$, its value is $\sum_{i=0}^ma_i3^i$.
Task: Given a decimal number $n$, convert and output its equivalent in balanced ternary, using x to represent $-1$.
Constraints: $-29524\le n\le 29524$.
Example Input
2
Example Output
1x