#include #include #include #include #include using ll = int64_t; using std::cin, std::cout; const ll max_n = 1e5+5, rt{1}; ll n, q, c[max_n], fts[max_n]; std::vector edges[max_n]; void fd_ft(const ll &ft, const ll &now){ fts[now] = ft; for(const ll &nxt: edges[now]){ if(nxt==ft)continue; fd_ft(now, nxt); } } int main(){ std::iostream::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr); cin>>n>>q; for(ll i{1};i<=n;i++){ cin>>c[i]; } for(ll i{1};i>u>>v; edges[u].push_back(v); edges[v].push_back(u); } fd_ft(0, rt); for(ll i{1};i<=q;i++){ ll u, v; cin>>u>>v; std::set pts; pts.emplace(c[u]); while(v!=u){ pts.emplace(c[v]); v=fts[v]; } cout<