Fun Fibonacci#11663

Fun Fibonacci

1 second
128 megabytes
Medium

Find the value of the function

f(x, y) = \begin{cases} 0, & x \le 0~\text{or}~y \le 0 \\ f(x - 1, y - 2) + f(x - 2, y - 1) + F(x), & x \le y \\ f(x - 2, y - 2) + F(y), & x > y \end{cases}

where is the -th Fibonacci number, defined as follows:

Input

Three integers x, y, m~(0 \le x, y \le 500, m \le 10^9).

Output

Print the value of the function f(x, y)~mod~m.

Examples

Example 1

Loading
Loading