{"trustable":true,"prependHtml":"\u003cstyle type\u003d\u0027text/css\u0027\u003e\n .input, .output {\n border: 1px solid #888888;\n }\n .output {\n margin-bottom: 1em;\n position: relative;\n top: -1px;\n }\n .output pre, .input pre {\n background-color: #EFEFEF;\n line-height: 1.25em;\n margin: 0;\n padding: 0.25em;\n }\n \u003c/style\u003e\n \u003clink rel\u003d\"stylesheet\" href\u003d\"//codeforces.org/s/96598/css/problem-statement.css\" type\u003d\"text/css\" /\u003e\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 type\u003d\"text/javascript\" async src\u003d\"https://mathjax.codeforces.org/MathJax.js?config\u003dTeX-AMS_HTML-full\"\u003e\u003c/script\u003e","sections":[{"title":"","value":{"format":"HTML","content":"\u003cp\u003eFirdaws and Fatinah are living in a country with $$$n$$$ cities, numbered from $$$1$$$ to $$$n$$$. Each city has a risk of kidnapping or robbery.\u003c/p\u003e\u003cp\u003eFirdaws\u0027s home locates in the city $$$u$$$, and Fatinah\u0027s home locates in the city $$$v$$$. Now you are asked to find the shortest path from the city $$$u$$$ to the city $$$v$$$ that does not pass through any other city with the risk of kidnapping or robbery higher than $$$w$$$, a threshold given by Firdaws.\u003c/p\u003e"}},{"title":"Input","value":{"format":"HTML","content":"\u003cp\u003eThe input contains several test cases, and the first line is a positive integer $$$T$$$ indicating the number of test cases which is up to $$$50$$$.\u003c/p\u003e\u003cp\u003eFor each test case, the first line contains two integers $$$n~(1\\le n\\le 200)$$$ which is the number of cities, and $$$q~(1\\le q\\le 2\\times 10^4)$$$ which is the number of queries that will be given. The second line contains $$$n$$$ integers $$$r_1, r_2, \\cdots, r_n$$$ indicating the risk of kidnapping or robbery in the city $$$1$$$ to $$$n$$$ respectively. Each of the following $$$n$$$ lines contains $$$n$$$ integers, the $$$j$$$-th one in the $$$i$$$-th line of which, denoted by $$$d_{i,j}$$$, is the distance from the city $$$i$$$ to the city $$$j$$$.\u003c/p\u003e\u003cp\u003eEach of the following $$$q$$$ lines gives an independent query with three integers $$$u, v$$$ and $$$w$$$, which are described as above.\u003c/p\u003e\u003cp\u003eWe guarantee that $$$1\\le r_i \\le 10^5$$$, $$$1\\le d_{i,j}\\le 10^5~(i \\neq j)$$$, $$$d_{i,i}\u003d0$$$ and $$$d_{i,j}\u003dd_{j,i}$$$. Besides, each query satisfies $$$1\\le u,v\\le n$$$ and $$$1\\le w\\le 10^5$$$.\u003c/p\u003e"}},{"title":"Output","value":{"format":"HTML","content":"\u003cp\u003eFor each test case, output a line containing \u003cspan class\u003d\"tex-font-style-tt\"\u003eCase #x:\u003c/span\u003e at first, where \u003cspan class\u003d\"tex-font-style-tt\"\u003ex\u003c/span\u003e is the test case number starting from $$$1$$$. Each of the following $$$q$$$ lines contains an integer indicating the length of the shortest path of the corresponding query.\u003c/p\u003e"}},{"title":"Examples","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\u003e1\n3 6\n1 2 3\n0 1 3\n1 0 1\n3 1 0\n1 1 1\n1 2 1\n1 3 1\n1 1 2\n1 2 2\n1 3 2\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003eCase #1:\n0\n1\n3\n0\n1\n2\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}}]}