Page not loading? Try clicking here.
Placeholder

#3106

Base Conversion 1s 64MB

Problems

Write a program that, given a number S in base A, converts it to base B.

The digits used in S can be 0–9 and A–Z.
Constraints: 2 ≤ A, B ≤ 36, and the decimal value of S is between 0 and 2^{63} − 1.


Input

The input consists of at most 100 test cases, each on a separate line.

The end of input is indicated by a line containing 0.

Each test case contains three values separated by spaces: A, S, B.


Output

For each test case, print the number S converted from base A to base B on a separate line.


Example #1

2 11010 8

2 10110 10
10 2543 16
16 ABC 8
0
32

22
9EF
5274

Example #2

19 23IEIAE43 11 
9 145287560667 2
0
14A10226AA8
101100001000111000101010011111100001


Source

JUNGOL - comkiwer

You must sign in to write code.