{"problem":{"name":"Min Product Sum","description":{"content":"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 ","description_type":"Markdown"},"platform":"AtCoder","limit":{"time_limit":6000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"agc039_f"},"statements":[{"statement_type":"Markdown","content":"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$.\n\n*   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.\n\n## Constraints\n\n*   $1 \\leq N,M,K \\leq 100$\n*   $10^8 \\leq D \\leq 10^9$\n*   $N,M,K,$ and $D$ are integers.\n*   $D$ is prime.\n\n## Input\n\nInput is given from Standard Input in the following format:\n\n$N$ $M$ $K$ $D$\n\n[samples]","is_translate":false,"language":"English"}],"meta":{"iden":"agc039_f","tags":[],"sample_group":[["2 2 2 998244353","35\n\nWe 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$."],["2 3 4 998244353","127090"],["31 41 59 998244353","827794103"]],"created_at":"2026-03-03 11:01:14"}}