Irreducible Polynomials High#4561

Irreducible Polynomials High

1 second
256 megabytes
Very easy

Let be a prime number. Consider \mathbf{Z}_p = \{0, 1, \ldots, p-1\} — the field of residues modulo . In this field, addition and multiplication operations are performed modulo .

Now consider monic polynomials over this field of the form

f(x) = x^n + a_{n-1}x^{n-1} + \ldots + a_1x + a_0,

where is the degree of the polynomial, is the variable, and the coefficients a_i belong to \mathbf{Z}_p.

For example, the polynomial x^2 + x + 1 over the field \mathbf{Z}_2 is irreducible. A monic polynomial is called irreducible if it cannot be written as f(x) = p(x) \cdot q(x), where p(x), q(x) are polynomials of degree less than that of . And it is the only irreducible degree 2 monic polynomial over the field \mathbf{Z}_2.

Your task is to compute the number of irreducible monic polynomials of degree over the field \mathbf{Z}_p. Since this number can be large, you need to find the remainder of this number when divided by .

Input

The input consists of a single line containing three integers , , (1 \leq p, n, m \leq 10^9).

Output

Print the remainder when the number of irreducible monic polynomials of degree over the field \mathbf{Z}_p is divided by .

Examples

Example 1

Loading
Loading