{"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\"\u003eRXD has a sequence $A_1,A_2,A_3,\\dots A_n$, which possesses the following properties:\u003cbr\u003e- $1\\leq A_i\\leq m$\u003cbr\u003e- $A_1 \u003d A_n \u003d 1$\u003cbr\u003e- for all $1\\leq x\\leq m$, there is at least one position $p$ where $A_p \u003d x$.\u003cbr\u003e- for all $x, y$, the number of $i(1 \\leq i \u0026lt; n)$ which satisfies $A_i \u003d x ~ and ~ A_{i + 1} \u003d y$ is $D_{x, y}$.\u003cbr\u003eOne day, naughty boy DXR clear the sequence.\u003cbr\u003eRXD wants to know, how many valid sequences are there.\u003cbr\u003eOutput the answer module $998244353$.\u003cbr\u003e$0\\leq D_{i, j}\u0026lt;500,1\\leq m\\leq 400$\u003cbr\u003e$n \\geq 2$\u003c/div\u003e"}},{"title":"Input","value":{"format":"HTML","content":"There are several test cases, please keep reading until EOF.\u003cbr\u003eThere are about 10 test cases, but only 1 of them satisfies $m \u0026gt; 50$\u003cbr\u003eFor each test case, the first line consists of 1 integer $m$, which means the range of the numbers in sequence.\u003cbr\u003eFor the next $m$ lines, in the $i$-th line, it consists of $m$ integers, the $j$-th integer means $D_{i, j}$.\u003cbr\u003eWe can easily conclude that $n \u003d 1 + \\sum_{i \u003d 1}^{m}\\sum_{j \u003d 1}^{m}{D_{i, j}}$."}},{"title":"Output","value":{"format":"HTML","content":"For each test case, output \"Case #x: y\", which means the test case number and the answer."}},{"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\n1 2\r\n2 1\r\n4\r\n1 0 0 2\r\n0 3 0 1\r\n2 1 0 0\r\n0 0 3 1\r\n4\r\n0 1 0 0\r\n1 0 0 0\r\n0 0 0 1\r\n0 0 1 0\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003eCase #1: 6\r\nCase #2: 18\r\nCase #3: 0\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}}]}