{"trustable":true,"prependHtml":"\u003cstyle type\u003d\"text/css\"\u003e\n #problem-body \u003e pre {\n display: block;\n padding: 9.5px;\n margin: 0 0 10px;\n font-size: 13px;\n line-height: 1.42857143;\n word-break: break-all;\n word-wrap: break-word;\n color: #333;\n background: rgba(255, 255, 255, 0.5);\n border: 1px solid #ccc;\n border-radius: 6px;\n }\n\u003c/style\u003e\n","sections":[{"title":"","value":{"format":"HTML","content":"\u003cdiv id\u003d\"problem-body\"\u003e\n\t\u003cp\u003eYou are given a tree with \u003cstrong\u003eN\u003c/strong\u003e nodes. The tree nodes are numbered from \u003cstrong\u003e1\u003c/strong\u003e to \u003cstrong\u003eN\u003c/strong\u003e. Each node has an integer weight.\u003c/p\u003e\r\n\u003cp\u003eWe will ask you to perform the following operation:\u003c/p\u003e\r\n\u003cul\u003e\r\n \u003cli\u003e\u003cstrong\u003eu v k\u003c/strong\u003e : ask for the kth minimum weight on the path from node \u003cstrong\u003eu\u003c/strong\u003e to node \u003cstrong\u003ev\u003c/strong\u003e\u003c/li\u003e\r\n\u003c/ul\u003e\r\n\r\n\u003ch3\u003eInput\u003c/h3\u003e\r\n\u003cp\u003eIn the first line there are two integers \u003cstrong\u003eN\u003c/strong\u003e and \u003cstrong\u003eM\u003c/strong\u003e. (\u003cstrong\u003eN, M\u003c/strong\u003e \u0026lt;\u003d 100000)\u003c/p\u003e\r\n\u003cp\u003eIn the second line there are \u003cstrong\u003eN\u003c/strong\u003e integers. The ith integer denotes the weight of the ith node.\u003c/p\u003e\r\n\u003cp\u003eIn the next \u003cstrong\u003eN-1\u003c/strong\u003e lines, each line contains two integers \u003cstrong\u003eu\u003c/strong\u003e \u003cstrong\u003ev\u003c/strong\u003e, which describes an edge (\u003cstrong\u003eu\u003c/strong\u003e, \u003cstrong\u003ev\u003c/strong\u003e).\u003c/p\u003e\r\n\u003cp\u003eIn the next \u003cstrong\u003eM\u003c/strong\u003e lines, each line contains three integers \u003cstrong\u003eu\u003c/strong\u003e \u003cstrong\u003ev\u003c/strong\u003e \u003cstrong\u003ek\u003c/strong\u003e, which means an operation asking for the kth minimum weight on the path from node \u003cstrong\u003eu\u003c/strong\u003e to node \u003cstrong\u003ev\u003c/strong\u003e.\u003c/p\u003e\r\n\r\n\u003ch3\u003eOutput\u003c/h3\u003e\r\n\u003cp\u003eFor each operation, print its result.\u003c/p\u003e\r\n\r\n\u003ch3\u003eExample\u003c/h3\u003e\r\n\u003cdiv\u003e\u003ctable class\u003d\"vjudge_sample\"\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\u003e8 5\r\n105 2 9 3 8 5 7 7\r\n1 2\r\n1 3\r\n1 4\r\n3 5\r\n3 6\r\n3 7\r\n4 8\n2 5 1\n2 5 2\n2 5 3\n2 5 4\n7 8 2\u0026nbsp;\r\n\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e2\n8\n9\n105\n7\u0026nbsp;\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n\u003c/div\u003e\n\u003c/div\u003e"}}]}