Faulty Factorial

Given n, prime p, and target r mod p, find the faulty factorial (one factor reduced below its index) with remainder r, printing the smallest such (index, value).

Hard8Number theoryMathImplementationBinary searchNo attempts yetTime limit3sMemory limit512 MB

Problem

The factorial of a natural number is the product of all positive integers up to that number. For example, the factorial of 44 is 1×2×3×4=241 \times 2 \times 3 \times 4 = 24. A faulty factorial of length nn has the same shape as the factorial of nn, but exactly one of the multiplied integers is strictly smaller than it should be. The reduced value is still at least 11. For example, 1×2×2×4=161 \times 2 \times 2 \times 4 = 16 is a faulty factorial of length 44.

You are given the length nn, a prime modulus pp, and a target remainder rr. Find a faulty factorial of length nn that leaves remainder rr when divided by pp.

Input

The first line contains the length nn of the faulty factorial, the prime modulus pp, and the target remainder rr, separated by spaces (2n10182 \le n \le 10^{18}, 2p<1072 \le p < 10^7, 0r<p0 \le r < p). The number pp is prime.

Output

If no faulty factorial meets the requirement, print -1 -1. Otherwise print the index kk of the fault and the value vv at that index, separated by a space (2kn2 \le k \le n, 1v<k1 \le v < k).

If several pairs work, print the lexicographically smallest pair (k,v)(k, v). That is, take the smallest kk, and among the answers with that kk take the smallest vv.

Note

The answer for the first example describes the faulty factorial 1×2×2×4=161 \times 2 \times 2 \times 4 = 16. Dividing 1616 by 55 leaves remainder 11.