Programming Problem #41
"Gray Codes Revisited Again Once More"

When numbers are written in binary (base 2), numbers that differ by only 1 may have very different representations. For example, 15 in binary is 1111, but adding one yields 16, which is 10000 in binary. All of the bits (binary digits) of the numbers are different. There are some applications in which it is advantageous to use a binary representation in which two numbers that differ by 1 have all but one bit in common. One such representation is the Gray code. The numbers from 0 to 8 using Gray codes are 0, 1, 11, 10, 110, 111, 101, 100, and 1100.

Converting a binary number b to its Gray code g is easy: just shift the bits in b one bit to the right, and then exclusive-or the result with the original b. In C, g = b ^ (b >> 1).

Converting from Gray back to binary is more difficult. The ith bit of b is obtained by exclusive-oring the ith bit of g and all the bits to its left in g. Your problem is to read in one or more decimal integers, one per line, and convert them from Gray to binary. For example, 12 in binary is 1100, converting 1100 from Gray to binary yields 1000, and 1000 binary is 8 in decimal, so an input of 12 should produce an output of 8. Use 32-bit unsigned integers, and output the result with no leading zeroes. A value of 0 signals the end of the input.

Input must be read from the file prob41.in, and output must be written to the file prob41.out. All output to the screen will be ignored.

Example Input

12
31
0

Example Output

8
21
Dr. Eric Shade