The first line has two integers N and M. (1≤N,M≤100000)
The second line has N integers, the weights of the vertices. The i-th integer is the weight of vertex i. All weights are different, and each one fits in a signed 32-bit integer.
Each of the next N-1 lines has two integers X and Y, meaning vertex X and vertex Y are joined by an edge.
Each of the next M lines has three integers X, Y, and K. X and Y are between 1 and N. K is at least 1 and at most the number of vertices on the path between vertex X and vertex Y. If X and Y are the same, that path holds 1 vertex.