URI Online Judge | 1193

Base Conversion

By Neilor Tonin, URI Brazil

Timelimit: 3

The Julian math teacher has marked a test whose content will be on converting between decimal, hexadecimal and binary numbers. For Julian, this kind of convertion is one of the most complex things to be done. Regardless of the time spent for studying these contents, he simple doesn't understand. So, as you understand about computing and being a friend of Julian, he asked for your help to make a program that checks if the conversions made ​​by him are correct.


The input contains many test cases. The first line of input contains an integer N indicating the number of test cases that follow, one by line. Each test case contains a number X (X > 0) followed by a Y text with three characters, indicating if the X number is in binary, decimal or hexadecimal. Regardless of the format, any of the numbers must fit into a 32-bit integer.


For each test case, Julian wants that you print the number of the test case folloed by two lines, that contains the oiginal number converted for each one of the other two bases. The sequence of the bases of output is always: decimal, hexadecimal (lowercase) and binary, ie must respect this order obviously excluding the input format.

Note: should print a blank line after each test case, even after the last test case.

Input Sample Output Sample

101 bin
101 dec
8f hex

Case 1:
5 dec
5 hex

Case 2:
65 hex
1100101 bin

Case 3:
143 dec
10001111 bin