ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules

1468. Fraction

Time limit: 0.4 second
Memory limit: 64 MB
There are two numbers, a and b. It is required to calculate the value a/b and write it in the k-based number system.

Input

The input consists of several tests (not more than 100) separated by a line break. Each test consists of three integers 1 ≤ a ≤ 10000, 1 ≤ b ≤ 10000, 2 ≤ k ≤ 36. There are two zeros in the last line.

Output

For each test, output a line containing the representation of the number a/b in the k-based number system. The integer part must be separated from the fractional part by a point. If the number a/b is whole, then there should be no point. The output must not contain insignificant zeros. If the fraction a/b is periodic, then its period must be given in parentheses.

Sample

inputoutput
10 5 2
1 2 8
8780 1 29
2794 6083 23
157 7 19
1 12 10
0 0
10
0.4
ACM
0.(ACM)
13.(82DAG5)
0.08(3)
Problem Author: Dmitry Zhukov
Problem Source: Ural SU and Orel STU Contest. Petrozavodsk Summer Session, August 2006