#00007C

z-polinom

You are given three integers A, N and M. Calculate the value of the following expression, modulo M: A^0 + A^1 + ... + A^N.


InputIn the first line of the standard input there are three integers, A, N and M (1 <= A, N, M <= 10^9).

OutputPrint the result to the first line of standard output.


Input:
2 3 10
Output:
5
Note:
2^0 + 2^1 + 2^2 + 2^3 = 1 + 2 + 4 + 8 = 15. 15 modulo 10 = 5.

Submit solution

Coming later

The grading service will be connected in a later migration step. You can inspect the task and your previous results now.