J. Jester's Paint Parade
time limit per test
2 seconds
memory limit per test
1024 megabytes
input
standard input
output
standard output

In the Grand Palace of the Fruits Kingdom, there is a long ornamental chain consisting of $$$n$$$ decorative beads, numbered from $$$1$$$ to $$$n$$$ from left to right. Initially, all beads are uncolored.

To celebrate the upcoming Fruits' Festival, the King has invited $$$m$$$ jesters to color the beads. The jesters are numbered from $$$1$$$ to $$$m$$$. The coloring process runs for $$$m$$$ turns, in the $$$i$$$-th turn, the $$$i$$$-th jester must paint a contiguous segment of the beads with color $$$i$$$. However, the jesters do not view themselves as ordinary performers, instead, all of them are strictly adhered to the sacred number $$$k$$$, insisting that each jester's stroke must cover exactly $$$k$$$ beads. It follows that each jester has $$$n - k + 1$$$ choices in their turn.

Note that painting a colored bead will overwrite its original color.

Since the jesters are paid, the king does not want to see uncolored beads at the ceremony. Thus, all $$$n$$$ beads must be painted by at least one of the jesters by the end of the process.

Please help the King calculate the total number of possible final states of the beads that satisfy the condition above. Two final states are considered different if and only if there exists a bead $$$i$$$ that has a different color in the two states. Since the answer could be large, output it modulo $$$p$$$.

Input

The input contains four integers $$$n, m, k, p$$$, representing the number of beads, the number of jesters, the sacred number and the modulo.

  • $$$2 \leq k \leq n \leq 4000$$$
  • $$$1 \leq m \leq 10^8$$$
  • $$$10^8 \leq p \leq 10^9$$$, $$$p$$$ is prime.
Output

Output a single integer, representing the total number of valid final states modulo $$$p$$$.

Examples
Input
4 2 3 588100627
Output
2
Input
5 3 2 573793837
Output
10
Input
4000 100000000 30 809157511
Output
808328768
Note

In the first sample, there are two possible coloring processes:

  • The first jester paints beads $$$1, 2, 3$$$, and the second jester paints beads $$$2, 3, 4$$$. The final state is $$$[1, 2, 2, 2]$$$.
  • The first jester paints beads $$$2, 3, 4$$$, and the second jester paints beads $$$1, 2, 3$$$. The final state is $$$[2, 2, 2, 1]$$$.

Note that they can't both paint beads $$$1, 2, 3$$$, since bead $$$4$$$ will be uncolored and violate the King's requirement.