{"trustable":true,"prependHtml":"\u003cscript\u003e window.katexOptions \u003d { disable: true }; \u003c/script\u003e\n\u003cscript type\u003d\"text/x-mathjax-config\"\u003e\n MathJax.Hub.Config({\n tex2jax: {\n inlineMath: [[\u0027$$$\u0027,\u0027$$$\u0027], [\u0027$\u0027,\u0027$\u0027]],\n displayMath: [[\u0027$$$$$$\u0027,\u0027$$$$$$\u0027], [\u0027$$\u0027,\u0027$$\u0027]]\n }\n });\n\u003c/script\u003e\n\u003cscript async src\u003d\"https://mathjax.codeforces.org/MathJax.js?config\u003dTeX-AMS-MML_HTMLorMML\" type\u003d\"text/javascript\"\u003e\u003c/script\u003e","sections":[{"title":"","value":{"format":"HTML","content":"\u003cdiv class\u003d\"panel_content\"\u003eNash Equilibrium is an important concept in game theory.\u003cbr\u003e\u003cbr\u003eRikka 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\u003eIn the remaining part of this statement, we use $(i,j)$ to denote the strategy of Yuta and Rikka.\u003cbr\u003e\u003cbr\u003eFor example, when $n\u003dm\u003d3$ and matrix $A$ is \u003cbr\u003e\\begin{align*}\u003cbr\u003e\\begin{bmatrix}\u003cbr\u003e1 \u0026amp; 2 \u0026amp; 1\\\\\u003cbr\u003e1 \u0026amp; 4 \u0026amp; 3\\\\\u003cbr\u003e1 \u0026amp; 1 \u0026amp; 1\\\\\u003cbr\u003e\\end{bmatrix}\u003cbr\u003e\\end{align*}\u003cbr\u003eIf the strategy is $(1,2)$, the score will be $2$; if the strategy is $(2,2)$, the score will be $4$.\u003cbr\u003e\u003cbr\u003eA 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\\begin{align*}\u003cbr\u003e\\begin{cases}\u003cbr\u003eA_{x,y} \\geq A_{i,y} \\ \\ \\forall i \\in [1, n] \\\\\u003cbr\u003eA_{x,y} \\geq A_{x,j} \\ \\ \\forall j \\in [1,m]\u003cbr\u003e\\end{cases}\u003cbr\u003e\\end{align*}\u003cbr\u003e\u003cbr\u003eIn the previous example, there are two pure strategy Nash equilibriums: $(3,1)$ and $(2,2)$.\u003cbr\u003e\u003cbr\u003eTo make the game more interesting, Rikka wants to construct a matrix $A$ for this game which satisfies the following conditions:\u003cbr\u003e1. Each integer in $[1, nm]$ occurs exactly once in $A$.\u003cbr\u003e2. The game has at most one pure strategy Nash equilibriums. \u003cbr\u003e\u003cbr\u003eNow, Rikka wants you to count the number of matrixes with size $n \\times m$ which satisfy the conditions.\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\u003eThe 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\u003eThe 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\u003e2\r\n3 3 100\r\n5 5 2333\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e64\r\n1170\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}}]}