{"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\"\u003e村庄里有n个房子,它们之间有一些双向道路相连。每天人们总是喜欢问这样的问题:“如果我想从A房子到B房子要走多远?”通常很难回答。但幸运的是,在这个村庄里答案总是唯一的,因为道路建造得这样,每两个房子之间都有一条唯一的简单路径(“简单”意味着你不能重复访问一个地方)。你的任务是回答所有这些好奇的人。\u003c/div\u003e"}},{"title":"输入","value":{"format":"HTML","content":"第一行是一个整数T(T\u0026lt;\u003d10),表示测试用例的数量。\u003cbr\u003e\u0026nbsp;\u0026nbsp;对于每个测试用例,第一行有两个数字n(2\u0026lt;\u003dn\u0026lt;\u003d40000)和m(1\u0026lt;\u003dm\u0026lt;\u003d200),分别表示房子的数量和查询的数量。接下来的n-1行每行包含三个数字i,j,k,用一个空格分隔,表示连接房子i和房子j的道路长度为k(0\u0026lt;k\u0026lt;\u003d40000)。房子从1到n编号。\u003cbr\u003e\u0026nbsp;\u0026nbsp;接下来的m行每行包含不同的整数i和j,你需要回答房子i和房子j之间的距离。"}},{"title":"输出","value":{"format":"HTML","content":"对于每个测试用例,输出m行。每行表示一个查询的答案。在每个测试用例之后输出一个空行。"}},{"title":"样例","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 2\r\n1 2 10\r\n3 1 15\r\n1 2\r\n2 3\r\n\r\n2 2\r\n1 2 100\r\n1 2\r\n2 1\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e10\r\n25\r\n100\r\n100\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e"}}]}