{"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\u003eGiven a weighted tree $$$T_0$$$, we define its diameter as the length of the longest path between two vertices on it, where the length of a path is equal to the sum of weights of edges in the path.\u003c/p\u003e\u003cp\u003eIf the tree stretches like a spider or a yawning tiger, its diameter will change. Let\u0027s use $$$T_i$$$ to denote the state of the tree after $$$i$$$ seconds, at which time the weight of each edge has been increased by exactly $$$i$$$ units from $$$T_0$$$.\u003c/p\u003e\u003cp\u003eYou will be presented with several different queries, and you should calculate the tree\u0027s diameter at some specified time for each query.\u003c/p\u003e"}},{"title":"Input","value":{"format":"HTML","content":"\u003cp\u003eThe input contains several test cases, and the first line contains a positive integer $$$T$$$ indicating the number of test cases which is up to $$$60$$$.\u003c/p\u003e\u003cp\u003eFor each test case, the first line contains two integers $$$n$$$ and $$$m$$$ indicating the number of vertices in the tree and the number of given queries respectively, where $$$2 \\le n \\le 2 \\times 10^5$$$ and $$$1 \\le m \\le 2 \\times 10^5$$$.\u003c/p\u003e\u003cp\u003eEach of the following $$$(n - 1)$$$ lines contains three integers $$$u, v$$$ and $$$w$$$ which represent an edge in the original tree between the $$$u$$$-th vertex and the $$$v$$$-th one of weight $$$w$$$, where $$$1 \\le u, v \\le n$$$, $$$u \\ne v$$$ and $$$1 \\le w \\le 10^8$$$.\u003c/p\u003e\u003cp\u003eEach of the following $$$m$$$ lines describes a query containing only one integer $$$k$$$ that asks you to calculate the diameter of the tree $$$T_k$$$, where $$$0 \\le k \\le 10^9$$$.\u003c/p\u003e\u003cp\u003eWe guarantee that the sum of $$$n$$$ in all test cases is no larger than $$$10^6$$$, and the sum of $$$m$$$ in all test cases is no larger than $$$10^6$$$ as well.\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\" (without quotes) at first, where \u003cspan class\u003d\"tex-font-style-tt\"\u003ex\u003c/span\u003e is the test case number starting from $$$1$$$.\u003c/p\u003e\u003cp\u003eThen output $$$m$$$ lines corresponding to all queries. The $$$i$$$-th line of them contains an integer indicating the answer to the $$$i$$$-th 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\u003e2\n3 3\n1 2 1\n1 3 5\n5\n10\n100\n5 6\n1 2 100\n2 3 5\n2 4 1\n4 5 1\n0\n1\n2\n3\n4\n5\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003eCase #1:\n16\n26\n206\nCase #2:\n105\n107\n109\n111\n114\n117\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}},{"title":"Note","value":{"format":"HTML","content":"\u003cp\u003eIn the second sample case:\u003c/p\u003e\u003cul\u003e \u003cli\u003e the diameter of $$$T_0$$$ is $$$105$$$, which is the length of the path $$$1 - 2 - 3$$$; and \u003c/li\u003e\u003cli\u003e the diameter of $$$T_5$$$ is $$$117$$$, which is the length of the path $$$1 - 2 - 4 - 5$$$. \u003c/li\u003e\u003c/ul\u003e"}}]}