atcoder#AGC035E. [AGC035E] Develop

[AGC035E] Develop

Score : 16001600 points

Problem Statement

There is a blackboard on which all integers from 1018-10^{18} through 101810^{18} are written, each of them appearing once. Takahashi will repeat the following sequence of operations any number of times he likes, possibly zero:

  • Choose an integer between 11 and NN (inclusive) that is written on the blackboard. Let xx be the chosen integer, and erase xx.
  • If x2x-2 is not written on the blackboard, write x2x-2 on the blackboard.
  • If x+Kx+K is not written on the blackboard, write x+Kx+K on the blackboard.

Find the number of possible sets of integers written on the blackboard after some number of operations, modulo MM. We consider two sets different when there exists an integer contained in only one of the sets.

Constraints

  • 1KN1501 \leq K\leq N \leq 150
  • 108M10910^8\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 possible sets of integers written on the blackboard after some number of operations, modulo MM.

3 1 998244353
7

Every set containing all integers less than 11, all integers greater than 33, and at least one of the three integers 11, 22, and 33 satisfies the condition. There are seven such sets.

6 3 998244353
61
9 4 702443618
312
17 7 208992811
128832
123 45 678901234
256109226