atcoder#AGC039F. [AGC039F] Min Product Sum

[AGC039F] Min Product Sum

Score : 20002000 points

Problem Statement

For each of the KNMK^{NM} ways to write an integer between 11 and KK (inclusive) in every square in a square grid with NN rows and MM columns, find the value defined below, then compute the sum of all those KNMK^{NM} values, modulo DD.

  • For each of the NMNM squares, find the minimum among the N+M1N+M-1 integers written in the square's row or the square's column. The value defined for the grid is the product of all these NMNM values.

Constraints

  • 1N,M,K1001 \leq N,M,K \leq 100
  • 108D10910^8 \leq D \leq 10^9
  • N,M,K,N,M,K, and DD are integers.
  • DD is prime.

Input

Input is given from Standard Input in the following format:

NN MM KK DD

Output

Print the sum of the KNMK^{NM} values, modulo DD.

2 2 2 998244353
35

We have 11 way to write integers such that the product of the NMNM values is 1616, 44 ways such that the product is 22, and 1111 ways such that the product is 11.

2 3 4 998244353
127090
31 41 59 998244353
827794103