{"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\"\u003eNoticeļ¼Don\u0027t output extra spaces at the end of one line.\u003cbr\u003e\u003cbr\u003eLet $p_1, p_2, \\cdots, p_n$ be a permutation of length $n$, Dodo bird built an array $a$ of length $n$ where $a_i$ indicates the size of the monotonic stack got from $p_1, p_2, \\cdots, p_i$. For instance, if $p$ is $3,1,4,5,6,2$, we add the elements in the permutation to the monotonic stack one by one, the changes of the monotonic stack is as follows:\u003cbr\u003e\u003cbr\u003e$$3 \\to 1 \\to 1,4 \\to 1,4,5 \\to 1,4,5,6 \\to 1,2$$\u003cbr\u003e\u003cbr\u003eSo the corresponding array $a$ is $1,1,2,3,4,2$.\u003cbr\u003e\u003cbr\u003eYears later, Dodo bird found the array $a$, but the value in some positions cannot be recognized anymore. He wants to know how many permutations can possibly be the original permutation. As the answer can be very large, you only need to output the answer module $10^9+7$.\u003c/div\u003e"}},{"title":"Input","value":{"format":"HTML","content":"The first line contains a number $T(1 \\leq T \\leq 100)$, indicating the number of test cases.\u003cbr\u003e\u003cbr\u003eEach test case contains two lines. The first line contains an integer $n(1 \\leq n \\leq 100)$, indicating the length of the permutation. The second line contains $n$ integers $a_1, a_2, \\cdots, a_n(-1 \\leq a_i \\leq n, a_i \\not\u003d 0)$, indicating the array $a$. $a_i\u003d-1$ represents that the value of this position cannot be recognized.\u003cbr\u003e"}},{"title":"Output","value":{"format":"HTML","content":"$T$ lines, each line is an integer, indicating the answer module $10^9 + 7$."}},{"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\u003e5\r\n6\r\n1 1 2 3 4 2\r\n3\r\n1 2 3\r\n3\r\n-1 -1 -1\r\n3\r\n1 1 1\r\n3\r\n3 3 3\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e5\r\n1\r\n6\r\n1\r\n0\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}}]}