Problem 389 -- Bascially Speaking

read problem

Tips

Another base conversion exercise.

This time a little bit complicated because you have to write base-n numbers convert to/from base-n numbers.

You can use base-10 as the bridge: convert anything into base-10 then convert the base-10 number into another base.

 

Test Cases

Input

1111000 2 10
1111000 2 16
2102101 3 10
2102101 3 15
12312 4 2
1A 15 2
1234567 10 16
ABCD 16 15
35213 6 5
852 7 13
004A01 11 15

Output

    120
     78
   1765
    7CA
  ERROR
  11001
 12D687
   D071
 130144
    270
   1E0A