Submit solution

Points:
7 (partial)

Time limit:
2.0s

Memory limit:
64M

PyPy 2
128M

PyPy 3
128M

Author:

Problem type

We define a good array as an array of length with all elements ranging from to inclusive, the first element of the array is equal to , and the last element of the array is equal to , and consecutive elements must be different from each other.

Given , , and , how many good arrays can you form, mod ?

#### Input Specification

One line containing , , , the constraints of a good array.

#### Subtask 1 [30%]

#### Subtask 2 [70%]

#### Output Specification

One integer, the number of good arrays that you can form, mod .

#### Sample Input 1

`4 3 2`

#### Sample Output 1

`3`

#### Sample Explanation 1

The good arrays you can form are , and .

#### Sample Input 2

`77 73 37`

#### Sample Output 2

`124047187`

## Comments