{"trustable":false,"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":"MD","content":"$\\bold{STF}$想要回老家过年,但春运期间各个城市交通都很繁忙。有$n$个城市,编号为$1,2,3...n$,每一个城市都有一个拥挤程度$r_i(i\u003d1,2...n)$,并且由于交通发达,每一对城市之间都有双向通行的公路直接连接。\n$\\bold{STF}$现在位于城市$u$,要前往老家所在城市$v$,并且不希望经过任何一个拥挤程度$r_i\u003ew$的城市(起点$u$和终点$v$除外),他想知道回老家的最短路径有多长。\n"}},{"title":"输入描述","value":{"format":"MD","content":"输入含有多组数据。\n第一行为正整数$T$(不超过50),代表测试数据组数。\n每一组测试数据的第一行为两个整数$n(1\\leq n\\leq200),q(1\\leq q\\leq 2\\cdot 10^4)$,代表城市的数目和询问的数目。\n第二行为$n$个正整数$r_1,r_2...r_n(1\\leq r_i\\leq 10^5)$,为各个城市的拥挤程度。\n接下来有$n$行,$n$行里的第$i$行$n$个整数$d_{i,1},d_{i,2}...,d_{i,j}...d_{i,n}(1\\leq d_{i,j}\\leq10^5)$,$d_{i,j}$代表了连接$i,j$两座城市的公路的长度。输入保证$d_{i,i}\u003d0(i\u003d1,2...n)$且$d_{i,j}\u003dd_{j,i}$。\n接下来有$q$行,每行有三个正整数$u,v,w(1\\leq u,v\\leq n,1\\leq w\\leq 10^5)$,描述一个询问:$\\bold{STF}$的起点在$u$,终点在$v$,不可经过拥挤程度超过$w$的城市($u$可能等于$v$)时的最短路径长度。"}},{"title":"输出描述","value":{"format":"MD","content":"对于每组测试数据输出$q+1$行,第一行先输出\"Case #x:\"(不带引号)其中x应替换为这一组测试数据的序号($1,2...T$)\n接下来的$q$行每一行一个整数$ans_i$,代表着第$i$个询问的最短路径长度。"}},{"title":"样例","value":{"format":"MD","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\n3 5 1\n0 1 1\n1 0 3\n1 3 0\n2 2 3\n2 3 1\n2 1 1\n2 3 3\n2 1 3\n2 2 1\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003eCase #1:\n0\n3\n1\n2\n1\n0\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}}]}