Problem B:
Number
Write a program to do number conversion. The input and output format could be in
binary, octal, decimal, or hexadecimal..
Input
The first line contains an integer m which indicates the number of test cases. In the
next m lines, each line is a test case.
The first number I is the input format -- 2 for binary, 10 for decimal, 8 for octal,
and 16 for hexadecimal. The second number N is the number of digits in the input
number. The following N numbers are input digits. The last number is the output
format O, and it has the format as I.
Output
The output has one line, with all the digits of the input number in O format. Two
digits are separated by a space.
Sample Input
3
165abcd010
166fedcba16
166fedcba8
Sample Output
703696
fedcba
77556272