{"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\"\u003eThere is a country with N cities.\u003cbr\u003e\u003cbr\u003eThese all cities are connected with roads and have no cycles.\u003cbr\u003e\u003cbr\u003eConsider all simple paths whose lengths are between L and R (both inclusive).\u003cbr\u003e\u003cbr\u003eYour task is to find the path that minimizes the k-th value of the path among them.\u003cbr\u003e\u003cbr\u003eThe k-th value of a simple path is “floor(length of path / k) + 1”-th value of the sorted length list of all roads in the path.\u003cbr\u003e\u003c/div\u003e"}},{"title":"Input","value":{"format":"HTML","content":"The first line contains a single integer T representing the number of test cases($1\\leq T\\leq 100$)\u003cbr\u003eSum of all $N\\leq 700000$\u003cbr\u003eThe first line of each test case contains a single integer N.\u003cbr\u003eEach of the following N – 1 lines contains 3 integers which represents two cities of the road and the length of the road.\u003cbr\u003eNext lines contains 3 integers k, L, R.\u003cbr\u003e\u003cbr\u003e$1\\leq N \\leq 10^5$\u003cbr\u003e$1\\leq a_i \\leq 10^9$\u003cbr\u003e$1 \\leq L \\leq R \\leq 50$\u003cbr\u003e$1\u0026lt;k\u0026lt;50$"}},{"title":"Output","value":{"format":"HTML","content":"Output the minimum k-th value of all simple paths whose length is between L and R.\u003cbr\u003e\u003cbr\u003eIf no such path exists output -1.\u003cbr\u003e"}},{"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\u003e1\r\n5\r\n1 2 1\r\n2 3 2\r\n3 4 3\r\n4 5 4\r\n2 3 4 \r\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e2\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}}]}