401733: GYM100519 E Equal Digits

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

Description

E. Equal Digitstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard output

For the given integer N and digit D, find the minimal integer K ≥ 2 such that the representation of N in the positional numeral system with base K contains the maximum possible consecutive number of digits D at the end.

Input

The input contains two integers N and D (0 ≤ N ≤ 1015, 0 ≤ D ≤ 9).

Output

Output two integers: K, the answer to the problem, and R, the the number of consecutive digits D at the end of the representation of N in the positional numeral system with base K.

ExamplesInput
3 1
Output
2 2
Input
29 9
Output
10 1
Input
0 4
Output
2 0
Input
90 1
Output
89 2

加入题单

算法标签: