Digit#3563

Digit

2 seconds
64 megabytes
Easy

For a positive integer , define the function as the sum of its digits in base . Also, let be the smallest such that S^k(a) does not exceed l-1, where S^k(a) means applying the function to times.

Given , find the smallest positive integer such that L(a) = N and output its value modulo .

Input

Each test case is given in a separate line containing three integers , , (0 \le N \le 10^5, 1 \le m \le 10^9, 2 \le l \le 10^9). The input contains several test cases, followed by a line containing 0 0 0.

Output

For each test case, output its case number and the minimal modulo .

Examples

Example

Input
1 5 10
2 1000 17
0 0 0
Output
1 1
2 10

Example 1

Loading
Loading