Under construction

Still being built. Things may change

Negative Binary

Interview

Time limit1sMemory limit128 MB

Summary
Convert each given decimal integer to its base negative two representation without leading zeros.
Level

Easy3 of 10

Topics
Math, Implementation
Solved
No attempts yet

Problem

In positional notation the rightmost place value is b0=1b^0 = 1, and every step to the left multiplies it by the base bb once more, giving b1b^1, b2b^2, and so on. With base −2-2 the place values read 1,−2,4,−8,16,−32,…1, -2, 4, -8, 16, -32, \dots from right to left. Counting up from 1 therefore goes 1, 110, 111, 100, 101, 11010, 11011, 11000, 11001, and so on.

Base −2-2 represents a negative number without a separate sign bit. Write a program that prints the decimal number NN in base −2-2.

Input

The first line has a positive integer TT, the number of test cases, with T≤100000T \le 100000.

Each of the next TT lines has one integer NN with −1017≤N≤1017-10^{17} \le N \le 10^{17}.

Output

For each test case print one line in the format Case #x: M, where xx is the case number starting from 1 and MM is the base −2-2 representation of NN.

MM carries no leading zero. When N=0N = 0, print 0.

Examples1

  1. Example 1

    Input
    15
    1
    -1
    2
    10
    0
    100
    -100
    50
    60
    1000
    -10000
    50000
    -25000
    12345
    -23456
    
    Expected output
    Case #1: 1
    Case #2: 11
    Case #3: 110
    Case #4: 11110
    Case #5: 0
    Case #6: 110100100
    Case #7: 11101100
    Case #8: 1110110
    Case #9: 1001100
    Case #10: 10000111000
    Case #11: 10100100110000
    Case #12: 11100011101010000
    Case #13: 1110001110101000
    Case #14: 111000001001001
    Case #15: 1110010110100000