Integer Flipping

No attempts yetTime limit1sMemory limit128 MB

Problem

Aliens have finally visited Earth. They are like us in every way except how they write integers in binary. We store an integer in a computer as a 32-bit binary number. The aliens use 32 bits too, but they read those bits in a completely different order.

Given an unsigned 32-bit number written our way, work out how the aliens would write it. The conversion takes two steps.

  1. Convert the number to its binary representation.
  2. Reverse the order of the bits.

Read the reversed binary number back as a positive, unsigned decimal the way we would, and that is the answer.

Say the numbers were 4 bits wide and you were given 4. In binary that is 010020100_2, and flipped it becomes 001020010_2. Read back as decimal, the answer is 2.

Input

Each line contains a single integer to flip, written in Earth's representation. A line starting with -1 marks the end of the input.

Output

For each integer given in Earth's representation, print the value the aliens read after flipping it, in decimal, one per line. Treat the input number as a 32-bit integer, reverse the order of its bits, then evaluate that 32-bit binary number as if it were still in Earth's representation and print the result.