{"trustable":false,"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 \u003cp\u003eYou are given a tree with $N$ nodes. The tree nodes are numbered from $1$ to $N$. Each node has an integer weight.\u003c/p\u003e\n \u003cp\u003eWe will ask you to perform the following operation:\u003c/p\u003e\n \u003cul\u003e\n \u003cli\u003e$u \\space v \\space k$ : ask for the $k-th$ minimum weight on the path from node $u$ to node $v$\u003c/li\u003e\n \u003c/ul\u003e\n"}},{"title":"","value":{"format":"HTML","content":" \u003ch3\u003eInput\u003c/h3\u003e\n \u003cp\u003eIn the first line there are two integers $N$ and $M$. $(N, M \\leq 100000)$\u003c/p\u003e\n \u003cp\u003eIn the second line there are $N$ integers. The $i-th$ integer denotes the weight of the $i-th$ node.\u003c/p\u003e\n \u003cp\u003eIn the next $N-1$ lines, each line contains two integers $u$ $v$, which describes an edge $(u,v)$.\u003c/p\u003e\n \u003cp\u003eIn the next $M$ lines, each line contains three integers $u$ $v$ $k$, which means an operation asking for the $k-th$ minimum weight on the path from node $u$ to node $v$.\u003c/p\u003e\n"}},{"title":"","value":{"format":"HTML","content":" \u003ch3\u003eOutput\u003c/h3\u003e\n \u003cp\u003eFor each operation, print its result.\u003c/p\u003e\n"}},{"title":"","value":{"format":"HTML","content":" \u003ch3\u003eExample\u003c/h3\u003e\n\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\u003e8 5\n105 2 9 3 8 5 7 7\n1 2\n1 3\n1 4\n3 5\n3 6\n3 7\n4 8\n2 5 1\n2 5 2\n2 5 3\n2 5 4\n7 8 2 \n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e2\n8\n9\n105\n7 \u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n\n"}}]}