#P1439D. INOI Final Contests

    ID: 5653 Type: RemoteJudge 3000ms 256MiB Tried: 0 Accepted: 0 Difficulty: (None) Uploaded By: Tags>combinatoricsdpfft*3100

INOI Final Contests

No submission language available for this problem.

Description

Today is the final contest of INOI (Iranian National Olympiad in Informatics). The contest room is a row with nn computers. All computers are numbered with integers from 11 to nn from left to right. There are mm participants, numbered with integers from 11 to mm.

We have an array aa of length mm where aia_{i} (1ain1 \leq a_i \leq n) is the computer behind which the ii-th participant wants to sit.

Also, we have another array bb of length mm consisting of characters 'L' and 'R'. bib_i is the side from which the ii-th participant enters the room. 'L' means the participant enters from the left of computer 11 and goes from left to right, and 'R' means the participant enters from the right of computer nn and goes from right to left.

The participants in the order from 11 to mm enter the room one by one. The ii-th of them enters the contest room in the direction bib_i and goes to sit behind the aia_i-th computer. If it is occupied he keeps walking in his direction until he reaches the first unoccupied computer. After that, he sits behind it. If he doesn't find any computer he gets upset and gives up on the contest.

The madness of the ii-th participant is the distance between his assigned computer (aia_i) and the computer he ends up sitting behind. The distance between computers ii and jj is equal to ij|i - j|.

The values in the array aa can be equal. There exist nm2mn^m \cdot 2^m possible pairs of arrays (a,b)(a, b).

Consider all pairs of arrays (a,b)(a, b) such that no person becomes upset. For each of them let's calculate the sum of participants madnesses. Find the sum of all these values.

You will be given some prime modulo pp. Find this sum by modulo pp.

The only line contains three integers nn, mm, pp (1mn500,108p109+91 \leq m \leq n \leq 500, 10^8 \leq p \leq 10 ^ 9 + 9).

It is guaranteed, that the number pp is prime.

Print only one integer — the required sum by modulo pp.

Input

The only line contains three integers nn, mm, pp (1mn500,108p109+91 \leq m \leq n \leq 500, 10^8 \leq p \leq 10 ^ 9 + 9).

It is guaranteed, that the number pp is prime.

Output

Print only one integer — the required sum by modulo pp.

Samples

Sample Input 1

3 1 1000000007

Sample Output 1

0

Sample Input 2

2 2 1000000009

Sample Output 2

4

Sample Input 3

3 2 998244353

Sample Output 3

8

Sample Input 4

20 10 1000000009

Sample Output 4

352081045

Note

In the first test, there are three possible arrays aa: {1}\{1\}, {2}\{2\}, and {3} \{3\} and two possible arrays bb: {L}\{\mathtt{L}\} and {R}\{\mathtt{R}\}. For all six pairs of arrays (a,b)(a, b), the only participant will sit behind the computer a1a_1, so his madness will be 00. So the total sum of madnesses will be 00.

In the second test, all possible pairs of arrays (a,b)(a, b), such that no person becomes upset are:

  • ({1,1},{L,L})(\{1, 1\}, \{\mathtt{L}, \mathtt{L}\}), the sum of madnesses is 11;
  • ({1,1},{R,L})(\{1, 1\}, \{\mathtt{R}, \mathtt{L}\}), the sum of madnesses is 11;
  • ({2,2},{R,R})(\{2, 2\}, \{\mathtt{R}, \mathtt{R}\}), the sum of madnesses is 11;
  • ({2,2},{L,R})(\{2, 2\}, \{\mathtt{L}, \mathtt{R}\}), the sum of madnesses is 11;
  • all possible pairs of a{{1,2},{2,1}}a \in \{\{1, 2\}, \{2, 1\}\} and b{{L,L},{R,L},{L,R},{R,R}}b \in \{\{\mathtt{L}, \mathtt{L}\}, \{\mathtt{R}, \mathtt{L}\}, \{\mathtt{L}, \mathtt{R}\}, \{\mathtt{R}, \mathtt{R}\}\}, the sum of madnesses is 00.

So, the answer is 1+1+1+1+0=41 + 1 + 1 + 1 + 0 \ldots = 4.