{"trustable":true,"sections":[{"title":"","value":{"format":"HTML","content":"\u003cdiv class\u003d\"panel_content\"\u003e\n Nash Equilibrium is an important concept in game theory.\u003cbr\u003e\u003cbr\u003e\n Rikka and Yuta are playing a simple matrix game. At the beginning of the game, Rikka shows an $n \\times m$ integer matrix $A$. And then Yuta needs to choose an integer in $[1,n]$, Rikka needs to choose an integer in $[1,m]$. Let $i$ be Yuta\u0027s number and $j$ be Rikka\u0027s number, the final score of the game is $A_{i,j}$. \u003cbr\u003e\u003cbr\u003e\n In the remaining part of this statement, we use $(i,j)$ to denote the strategy of Yuta and Rikka.\u003cbr\u003e\u003cbr\u003e\n For example, when $n\u003dm\u003d3$ and matrix $A$ is \u003cbr\u003e\n \\begin{align*}\u003cbr\u003e\n \\begin{bmatrix}\u003cbr\u003e\n 1 \u0026amp; 2 \u0026amp; 1\\\\\u003cbr\u003e\n 1 \u0026amp; 4 \u0026amp; 3\\\\\u003cbr\u003e\n 1 \u0026amp; 1 \u0026amp; 1\\\\\u003cbr\u003e\n \\end{bmatrix}\u003cbr\u003e\n \\end{align*}\u003cbr\u003e\n If the strategy is $(1,2)$, the score will be $2$; if the strategy is $(2,2)$, the score will be $4$.\u003cbr\u003e\u003cbr\u003e\n A pure strategy Nash equilibrium of this game is a strategy $(x,y)$ which satisfies neither Rikka nor Yuta can make the score higher by changing his(her) strategy unilaterally. Formally, $(x,y)$ is a Nash equilibrium if and only if:\u003cbr\u003e\n \\begin{align*}\u003cbr\u003e\n \\begin{cases}\u003cbr\u003e\n A_{x,y} \\geq A_{i,y} \\ \\ \\forall i \\in [1, n] \\\\\u003cbr\u003e\n A_{x,y} \\geq A_{x,j} \\ \\ \\forall j \\in [1,m]\u003cbr\u003e\n \\end{cases}\u003cbr\u003e\n \\end{align*}\u003cbr\u003e\u003cbr\u003e\n In the previous example, there are two pure strategy Nash equilibriums: $(3,1)$ and $(2,2)$.\u003cbr\u003e\u003cbr\u003e\n To make the game more interesting, Rikka wants to construct a matrix $A$ for this game which satisfies the following conditions:\u003cbr\u003e\n 1. Each integer in $[1, nm]$ occurs exactly once in $A$.\u003cbr\u003e\n 2. The game has at most one pure strategy Nash equilibriums. \u003cbr\u003e\u003cbr\u003e\n Now, Rikka wants you to count the number of matrixes with size $n \\times m$ which satisfy the conditions.\n\u003c/div\u003e"}},{"title":"Input","value":{"format":"HTML","content":"The first line contains a single integer $t(1 \\leq t \\leq 20)$, the number of the testcases.\u003cbr\u003e\u003cbr\u003e\nThe first line of each testcase contains three numbers $n,m$ and $K(1 \\leq n,m \\leq 80, 1 \\leq K \\leq 10^9)$.\u003cbr\u003e\u003cbr\u003e\nThe input guarantees that there are at most $3$ testcases with $\\max(n,m) \u0026gt; 50$."}},{"title":"Output","value":{"format":"HTML","content":"For each testcase, output a single line with a single number: the answer modulo $K$."}},{"title":"Sample","value":{"format":"HTML","content":"\u003ctable class\u003d\u0027vjudge_sample\u0027\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003eInput\u003c/th\u003e\n \u003cth\u003eOutput\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003e\u003cpre\u003e2\r\n3 3 100\r\n5 5 2333\r\n\u003c/pre\u003e\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e\u003cpre\u003e64\r\n1170\r\n\u003c/pre\u003e\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}}]}