{"raw_statement":[{"iden":"problem statement","content":"You are given a prime number $P$, which you don't like.\nLet's call an array of integers $A_1, A_2, \\dots, A_N$ **good**, if it is possible to reorder the elements in such a way that no prefix sum is divisible by $P$ (that is, there is **no** $i$ with $1 \\le i \\le N$ and $A_1 + A_2 + \\dots + A_i \\equiv 0 \\bmod P$ after the reordering).\nConsider all $(P-1)^N$ arrays of length $N$ with elements from $1$ to $P-1$. How many of them are **good**?\nAs this number can be very big, output it modulo $998244353$."},{"iden":"constraints","content":"*   $1 \\le N \\le 5000$\n*   $2 \\le P \\le 10^8$\n*   $P$ is a prime."},{"iden":"input","content":"Input is given from Standard Input in the following format:\n\n$N$ $P$"},{"iden":"sample input 1","content":"2 5"},{"iden":"sample output 1","content":"12\n\nThere are $12$ good arrays: $[1, 1]$, $[1, 2]$, $[1, 3]$, $[2, 1]$, $[2, 2]$, $[2, 4]$, $[3, 1]$, $[3, 3]$, $[3, 4]$, $[4, 2]$, $[4, 3]$, $[4, 4]$."},{"iden":"sample input 2","content":"4 3"},{"iden":"sample output 2","content":"8\n\nThere are $8$ good arrays: $[1, 1, 1, 2]$, $[1, 1, 2, 1]$, $[1, 2, 1, 1]$, $[2, 1, 1, 1]$, $[2, 2, 2, 1$\\], $[2, 2, 1, 2]$, $[2, 1, 2, 2]$, $[1, 2, 2, 2]$."},{"iden":"sample input 3","content":"5000 99999989"},{"iden":"sample output 3","content":"51699346"},{"iden":"sample input 4","content":"2021 307"},{"iden":"sample output 4","content":"644635349"}],"translated_statement":null,"sample_group":[],"show_order":["default"],"formal_statement":null,"simple_statement":null,"has_page_source":true}