{"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\"\u003ePfctgeorge is totally a tall rich and handsome guy. He plans to build a huge water transmission network that covers the whole southwest China. To save the fund, there will be exactly one path between two cities.\u003cbr\u003e\u003cbr\u003eSince the water every city provides and costs every day is different, he needs to transfer water from one particular city to another as much as possible in the next few days. However the pipes which connect the cities have a limited capacity for transmission. (Which means the water that transfer though the pipe should not exceed a particular amount) So he has to know the maximum water that the network can transfer in the next few days.\u003cbr\u003e\u003cbr\u003eHe thought it\u0027s a maximum flow problem, so he invites an expert in this field, Elfness (Also known as Xinhang senior sister) to help him figure it out.\u003cbr\u003e\u003cbr\u003eUnlike Pfctgeorge, Elfness quickly finds that this problem is much easier than a normal maximum flow problem, and is willing to help Pfctgeorge.\u003cbr\u003e\u003cbr\u003e\"Oh well, this problem is not a tough one. We can ...\"\u003cbr\u003e\u003cbr\u003eAbruptly, Pfctgeorge\u0027s iPhone rings, and ... the ringtone is Mo Di Da Biao Ke.\u003cbr\u003e\u003cbr\u003e\"You can make that? Excellent! \"Pfctgeorge hangs up his iPhone, and turns to Elfness.\u003cbr\u003e\u003cbr\u003e\"Here\u0027s good news for you. A construction team told me that every pipe\u0027s capacity can be extended for one day. And the price for extending one unit capacity varies from day to day. \"\u003cbr\u003e\u003cbr\u003e\"Eh well, that\u0027s a good news for you, not me. Now it\u0027s rather like a minimum cost ow problem, right? But it\u0027s still not a tough one, let me have a think. \"\u003cbr\u003e\u003cbr\u003eAfter a few seconds\u0027 thought, Elfness comes up with a simple solution.\u003cbr\u003e\u003cbr\u003e\"Ok, we can solve it like... \"\u003cbr\u003e\u003cbr\u003eAbruptly, here comes Mo Di Da Biao Ke again.\u003cbr\u003e\u003cbr\u003e\"Seriously? You can build new pipes? Thank you very much. \"\u003cbr\u003e\u003cbr\u003e\"OK, my dear Elfness, we got more good news. Another construction team said they can build one or more pipes between any two cities and their pipes are exactly like the original ones except that they only work for one day. And the capacity of the new pipes is only one, but they can be extended, too. Of course, their price to build a single pipe also varies in days. \"\u003cbr\u003e\u003cbr\u003e\"You mean the new pipes can be extended too? Wow, things are getting more interesting. Give me a few minutes. \"\u003cbr\u003e\u003cbr\u003eElfness takes out his new ultrabook which is awarded in VK cup and does some basic calculation.\u003cbr\u003e\u003cbr\u003e\"I get it. The problem can be solved ...\"\u003cbr\u003e\u003cbr\u003eMo Di Da Biao Ke again, but this time it\u0027s from Elfness\u0027s phone.\u003cbr\u003e\u003cbr\u003e\"As you see, I have to go out. But I know someone else who can also solve this; I\u0027ll recommend this guy for you. \"\u003cbr\u003e\u003cbr\u003eAnd of course, that poor guy is YOU. Help Pfctgeorge solve his problem, and then the favorability about you from Elfness will raise a lot.\u003c/div\u003e"}},{"title":"Input","value":{"format":"HTML","content":"The first line has a number T (T \u0026lt;\u003d 10) , indicating the number of test cases.\u003cbr\u003e\u003cbr\u003eThe first line of each test case is two integers N (1 \u0026lt;\u003d N \u0026lt;\u003d 100000) and M (1 \u0026lt;\u003d M \u0026lt;\u003d 100000), indicating the number of the city that the original network connects and the number of days when Pfctgeorge needs to know about the maximum water transmissions. Then next N - 1 lines each describe a pipe that connects two cities. The format will be like U, V , cap (1 \u0026lt;\u003d U, V \u0026lt;\u003d N and 0 \u0026lt;\u003d cap \u0026lt; 10000), which means the ids of the two cities the pipe connects and the transmission limit of the pipe. As is said in description, the network that the cities and pipes form is a tree (an undirected acyclic graph).\u003cbr\u003e\u003cbr\u003eThen next M lines of the test case describe the information about the next few days. The format is like\u003cb\u003e S, T, K, A, B(0 \u0026lt;\u003d K \u0026lt;\u003d 2^31 - 1, 1 \u0026lt;\u003d A, B \u0026lt;\u003d 2^31 - 1)\u003c/b\u003e. S means the source of the water while T means the sink. K means the total budget in the day. A means the cost for a construction team to build a new pipe and B means the cost for a construction team to extend the capacity of a pipe.\u003cbr\u003e\u003cbr\u003eI am glad to list the information of building a new pipe and extending the capacity.\u003cbr\u003e\u003cbr\u003e1. Pfctgeorge can build a new pipe between any two cities, no matter they have been directly connected or not. Pfctgeorge can build more than one new pipe between any two cities.\u003cbr\u003e2. The capacity of the pipe that was newly built is \u003cb\u003eone\u003c/b\u003e.\u003cbr\u003e3. Pfctgeorge can extend the capacity of any existed pipe including the newly built one and the original one.\u003cbr\u003e4. Each time you extend the capacity of one pipe, the capacity of that pipe increases one.\u003cbr\u003e5. The cost of building a new pipe is A and the cost of extending a pipe is B.\u003cbr\u003e6. You can take any constructions in any times and the only limit is to make sure the total costs not exceed the budget.\u003cbr\u003e7. \u003cb\u003eAll the work that construction team does only lasts one single day.\u003c/b\u003e\u003cbr\u003e"}},{"title":"Output","value":{"format":"HTML","content":"For every case, you should output \"Case #t:\" at first, without quotes. The t is the case number starting from 1.\u003cbr\u003eThen for each day, output the maximum water Pfctgeorge can transfer from S and T with a budget of K."}},{"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\u003e2\r\n5 1\r\n1 2 2\r\n1 3 5\r\n2 4 1\r\n4 5 2\r\n1 5 3 3 2\r\n5 5\r\n1 2 10\r\n2 3 2\r\n3 4 7\r\n2 5 7\r\n1 5 0 1 3\r\n1 3 0 2 3\r\n1 5 3 2 3\r\n1 2 7 3 1\r\n1 3 2 3 1\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003eCase #1:\r\n2\r\nCase #2:\r\n7\r\n2\r\n8\r\n17\r\n4\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}},{"title":"Hint","value":{"format":"HTML","content":"\u003cbr\u003eIn the first sample case, you can extend the capacity of the pipe which connects \u003ci\u003ecity2\u003c/i\u003e and \u003ci\u003ecity4\u003c/i\u003e by one, or just build a new pipe between \u003ci\u003ecity2\u003c/i\u003e and \u003ci\u003ecity4\u003c/i\u003e. "}}]}