Radix 32 Conversion

No attempts yetTime limit1sMemory limit64 MB

Problem

A number system with fixed radix rr uses only the digits {0,1,,r1}\{0, 1, \dots, r-1\}. The digit sequence (xn1,xn2,,x0)(x_{n-1}, x_{n-2}, \dots, x_0) has the value

X=i=0n1xiriX = \sum_{i=0}^{n-1} x_i r^i

The digit sets of the three systems used here are

  • R2={0,1}R_2 = \{0, 1\}
  • R10={0,1,2,3,4,5,6,7,8,9}R_{10} = \{0, 1, 2, 3, 4, 5, 6, 7, 8, 9\}
  • R32={0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V}R_{32} = \{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V\}

In radix 32, A is 10, B is 11, and in the same order V is 31.

Write a program that converts radix 32 numbers of at most 8 digits to radix 10 and to radix 2.

Input

The first line has the number of test cases nn (1n1001 \le n \le 100). Each of the next nn lines has one radix 32 number. Every number consists only of digits from R32R_{32} and its length is between 1 and 8. A number may start with a zero digit.

Output

For each radix 32 number, print two lines. The first line is the radix 10 value and the second line is the radix 2 representation.

Print the radix 10 value without leading zeros. Build the radix 2 representation by turning each radix 32 digit of the input into a 5 bit binary field, padded in front with zeros when it is shorter than five bits, and concatenating those fields in input order. So an input of kk digits produces a radix 2 line of exactly 5k5k characters.