407174: GYM102697 145 Star Wars

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

145. Star Warstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard output
This problem is worth 40 points.

You've traveled across a galaxy far, far away, and you land on a planet with two different alien species. Each alien species counts numbers in a different base. Aliens of the first species count numbers using base $$$a$$$, and aliens of the second species count numbers using base $$$b$$$. The base used by most humans is decimal, base 10.

The two alien species are about to start a war, because they cannot properly communicate in numbers. Your task is to convert a number from the first alien species, in base $$$a$$$, into base $$$b$$$, in order to avert the impending alien war.

Input

The first line of input contains two integers $$$a$$$ and $$$b$$$ less than or equal to 10: the number base used by the first alien species, and the number base used by the second alien species, respectively.

The second line of input contains a single integer $$$n$$$ in base $$$a$$$.

Output

Output $$$m$$$: the given integer, converted from base $$$a$$$ to base $$$b$$$.

ExamplesInput
7 9
63642
Output
23550
Input
10 3
8790971
Output
121112121221112
Input
5 6
3124
Output
1530

加入题单

算法标签: