#t292. 确定进制

确定进制

Determine the Base

Problem Background

Special for beginners, ^_^

Problem Description

6×9=426 \times 9 = 42 is wrong in decimal, but correct in base 1313, i.e.

613×913=42136_{13} \times 9_{13} = 42_{13}

and

4213=4×131+2×130=541042_{13} = 4 \times 13^1 + 2 \times 13^0 = 54_{10}

Your task is to write a program that reads three integers pp, qq, and rr, then determines a base B (2≤B≤16)B\ (2 \le B \le 16) such that p×q=rp \times q = r. If there are multiple choices for BB, output the smallest one. For example: p=11,q=11,r=121p = 11, q = 11, r = 121. Then

113×113=121311_3 \times 11_3 = 121_3

because

113=1×31+1×30=41011_3 = 1 \times 3^1 + 1 \times 3^0 = 4_{10}

and

$$121_3 = 1 \times 3^2 + 2 \times 3^1 + 1 \times 3^0 = 16_{10}$$

For base 1010, we have

1110×1110=1211011_{10} \times 11_{10} = 121_{10}

In this case you should output 33. If no suitable base exists, output 00.

Input Format

One line containing three integers pp, qq, rr, separated by single spaces. All digits of pp, qq, rr are decimal digits, and 1≤p,q,r≤1,000,0001 \le p, q, r \le 1{,}000{,}000.

Output Format

One integer: the smallest BB such that p×q=rp \times q = r holds. If no suitable BB exists, output 00.

Sample Input

6 9 42

Sample Output

13

Constraints

1s, 1024KiB for each test case.