AtCoder Grand Contest 039
F
Min Product Sum
AtCoder
⌀ 4060
原题
← E→
翻译中…

Problem Statement

翻译中…

For each of the $K^{NM}$ ways to write an integer between $1$ and $K$ (inclusive) in every square in a square grid with $N$ rows and $M$ columns, find the value defined below, then compute the sum of all those $K^{NM}$ values, modulo $D$.

翻译中…
  • For each of the $NM$ squares, find the minimum among the $N+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 $NM$ values.
翻译中…

Constraints

翻译中…
  • $1 \leq N,M,K \leq 100$
  • $10^8 \leq D \leq 10^9$
  • $N,M,K,$ and $D$ are integers.
  • $D$ is prime.
翻译中…

Input

翻译中…

Input is given from Standard Input in the following format:

翻译中…

N M K D

翻译中…

Output

翻译中…

Print the sum of the $K^{NM}$ values, modulo $D$.

翻译中…

样例

Input #1
2 2 2 998244353
Output #1
35
We have $1$ way to write integers such that the product of the $NM$ values is $16$, $4$ ways such that the product is $2$, and $11$ ways such that the product is $1$.
Input #2
2 3 4 998244353
Output #2
127090
Input #3
31 41 59 998244353
Output #3
827794103
题目信息
题号
agc039_f
时间限制
6 s
内存限制
1024 MB

题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。