atcoder#AGC024E. [AGC024E] Sequence Growing Hard

[AGC024E] Sequence Growing Hard

Score : 12001200 points

Problem Statement

Find the number of the possible tuples of sequences (A0,A1,...,AN)(A_0,A_1,...,A_N) that satisfy all of the following conditions, modulo MM:

  • For every ii (0iN)(0\leq i\leq N), AiA_i is a sequence of length ii consisting of integers between 11 and KK (inclusive);
  • For every ii (1iN)(1\leq i\leq N), Ai1A_{i-1} is a subsequence of AiA_i, that is, there exists 1xii1\leq x_i\leq i such that the removal of the xix_i-th element of AiA_i would result in a sequence equal to Ai1A_{i-1};
  • For every ii (1iN)(1\leq i\leq N), AiA_i is lexicographically larger than Ai1A_{i-1}.

Constraints

  • 1N,K3001 \leq N,K \leq 300
  • 2M1092 \leq M \leq 10^9
  • NN, KK and MM are integers.

Input

Input is given from Standard Input in the following format:

NN KK MM

Output

Print the number of the possible tuples of sequences (A0,A1,...,AN)(A_0,A_1,...,A_N), modulo MM.

2 2 100
5

Five tuples below satisfy the conditions:

  • (),(1),(1,1)(),(1),(1,1)
  • (),(1),(1,2)(),(1),(1,2)
  • (),(1),(2,1)(),(1),(2,1)
  • (),(2),(2,1)(),(2),(2,1)
  • (),(2),(2,2)(),(2),(2,2)
4 3 999999999
358
150 150 998244353
186248260