#c22604. 路径上的最小点权

路径上的最小点权

Minimum Node Weight on a Path

Problem Description

You are given a tree with nn nodes, numbered from 11 to nn, each with a node weight aia_i.

There are qq queries. Each query reads two integers u,vu, v and asks: what is the minimum node weight on the path from node uu to node vv?

Input Format

The first line contains two integers n,qn, q, the number of vertices and the number of queries.

The second line contains nn integers a1,a2,…,ana_1, a_2, \dots, a_n.

The following n−1n-1 lines each contain two integers u,vu, v, meaning there is an edge between node uu and node vv.

The following qq lines each contain two integers u,vu, v, representing one query.

Output Format

For each query, output one line containing an integer: the answer.

Sample Input

3 3
1 2 3
1 2
2 3
1 2
1 3
2 3

Sample Output

1
1
2

Constraints

For 100%100\% of the data, $1 \leq n, q \leq 10^5, 1 \leq a_i \leq 10^5, 1 \leq u, v \leq n, u \neq v$, and the input is guaranteed to form a tree.