Generalized Fibonacci Numbers#4806

Generalized Fibonacci Numbers

1 second
64 megabytes
Very easy

Generalized Fibonacci numbers F_n^{(k)} are defined as the following sequence:

Your task is to compute the remainder of dividing F_n^{(k)} by .

Input

The input file contains three integers: , and (1 \leq n, k \leq 10^6, 2 \leq p \leq 10^9).

Output

Output F_n^{(k)} \bmod p to the output file.

Examples

Example 1

Loading
Loading