eolymp
bolt
Try our new interface for solving problems
Problems

Homework

Homework

Little boy Vanya in mug on a number system were asked the following task: to translate the number of \textbf{X} in radix notation \textbf{s_1} in \textbf{s_2}. Without thinking, he called for help his best friend Pete, who was famous for the fact that the great know how to count to \textbf{10} on the fingers. After a few sleepless nights, the joint efforts of the guys coped with the task. However, in the next lesson, Vanya asked a similar problem, where \textbf{X}, unfortunately, more than \textbf{10}. Then they decided to go to Summer School Computer to write the generic program that solves the problem for any \textbf{X}, \textbf{s_1} and \textbf{s_2}. Your purpose - to fulfill the request of Vanya and Petya. \InputFile In the input your program has \textbf{3} numbers: the initial number \textbf{X}, the base number systems \textbf{s_1} and \textbf{s_2} (\textbf{2} ≤ \textbf{s_1}, \textbf{s_2} ≤ \textbf{10}). The number \textbf{X} in decimal system is less than \textbf{2·10^9}. \OutputFile The output should be a number equal to the number of \textbf{X} in the notation \textbf{s_2}, or \textbf{-1} if the input data is invalid.
Time limit 1 second
Memory limit 64 MiB
Input example #1
101 2 10
Output example #1
5