Skip to main content
Tuesday (24.11.2026) at 20:00: ALGOR Contest: Round #4 (Special Challenge) starts!

~/algor $ cat problems/bit-grey-kodi

Gray code

Easy 1000 ms 128 MB 30%
Share

The Gray code of a non-negative integer $x$ is the number $x \oplus \lfloor x / 2 \rfloor$ ($\oplus$ is bitwise XOR). For example, the Gray code of $6 = 110_{2}$ is $110_{2} \oplus 011_{2} = 101_{2} = 5$. A number $n$ is given. Find two numbers: the Gray code of $n$ and the number whose Gray code is $n$ (it is unique).

Binary representation of n, its shift by one position and their XOR; the same in the reverse direction

Input

One integer $n$.

Output

Two integers separated by a space: the Gray code of $n$ and the number whose Gray code is $n$.

Note

$0 \le n \lt 2^{60}$

Examples

Input #1
5
Output #1
7 6
Input #2
0
Output #2
0 0

Sign in to submit a solution

Signing up is free and takes a minute.