#include "bits/stdc++.h"
#pragma GCC optimize ("O3")
#define MAXN 300009
#define INF 1000000007
#define mp(x,y) make_pair(x,y)
#define all(v) v.begin(),v.end()
#define pb(x) push_back(x)
#define wr cout<<"----------------"<<endl;
#define ppb() pop_back()
#define tr(ii,c) for(__typeof((c).begin()) ii=(c).begin();ii!=(c).end();ii++)
#define ff first
#define ss second
#define my_little_dodge 46
#define debug(x)  cerr<< #x <<" = "<< x<<endl;
using namespace std;
 
typedef long long ll;
typedef pair<int,int> PII;
template<class T>bool umin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>bool umax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
vector<int>adj[MAXN];
pair<PII,PII>query[MAXN];
const int LOG=19;
int st[MAXN],en[MAXN],id[MAXN<<1],T;
int L[MAXN],R[MAXN],arr[MAXN],ans[MAXN];
int lca[MAXN],P[MAXN][LOG],lvl[MAXN];
int la[MAXN],ra[MAXN];
void dfs(int nd=1,int pr=-1){
	st[nd]=++T;
	id[T]=nd;
	tr(it,adj[nd])
		if(*it!=pr){
			P[*it][0]=nd;
			lvl[*it]=lvl[nd]+1;
			dfs(*it,nd);
		}
	en[nd]=++T;
	id[T]=nd;
}
int LCA(int u,int v){
	if(lvl[u]<lvl[v])swap(u,v);
	for(int i=LOG-1;i>=0;i--)
		if(P[u][i] and lvl[P[u][i]]>=lvl[v])
			u=P[u][i];
	if(u==v)return u;
	for(int i=LOG-1;i>=0;i--)
		if(P[u][i] and P[v][i]!=P[u][i])
			u=P[u][i],v=P[v][i];
	return P[u][0];
}	
int small[MAXN],big[MAXN],parity[MAXN];
const int BLOK=100;
const int K=500;
void work(int nd){nd=arr[nd]-1;
	parity[nd]^=1;
	big[nd/BLOK]+=2*parity[nd]-1;
	small[nd]=parity[nd];
}
int get(int l,int r){l--;r--;int ans=-1;
	while(l<=r and l%BLOK){if(small[l]){ans=l+1;break;}l++;}
	while(ans==-1 and l+BLOK-1<=r){
		if(big[l/BLOK]){
			while(!small[l])l++;
			ans=l+1;
		}l+=BLOK;
	}
	while(ans==-1 and l<=r){if(small[l]){ans=l+1;break;}l++;}
	return ans;
}
bool cmp(pair<PII,PII>x,pair<PII,PII>y){
	if(x.ff.ff/K!=y.ff.ff/K)	
		return (x.ff.ff<y.ff.ff);
	return (x.ff.ss<y.ff.ss);
}
int main(){
    //freopen("file.in", "r", stdin);
    int n,q;
    scanf("%d%d",&n,&q);
    for(int i=1;i<=n;i++)
    	scanf("%d",arr+i);
    for(int i=1;i<n;i++){
    	int u,v;
		scanf("%d%d",&u,&v);
		adj[u].pb(v);
		adj[v].pb(u);	
    }
    dfs();
	for(int j=1;j<LOG;j++)
	    for(int i=1;i<=n;i++)
			if(P[i][j-1])
				P[i][j]=P[P[i][j-1]][j-1];
    for(int i=1;i<=q;i++){
    	int u,v;
    	scanf("%d%d%d%d",&u,&v,la+i,ra+i);
    	lca[i]=LCA(u,v);
    	int l,r,f=0;
    	if(st[u]>st[v])swap(u,v);
    	if(u==lca[i])l=st[u],r=st[v];
    	else l=en[u],r=st[v],f=1;
    	query[i]=mp(mp(l,r),mp(i,f));
    }
    sort(query+1,query+q+1,cmp);
    int L=1,R=0;
    for(int i=1;i<=q;i++){
		int r=query[i].ff.ss,l=query[i].ff.ff;
		int ind=query[i].ss.ff,f=query[i].ss.ss;
		while(L>l)work(id[--L]);
		while(R<r)work(id[++R]);
		while(L<l)work(id[L++]);
		while(R>r)work(id[R--]);
		if(f)work(lca[ind]);
		ans[ind]=get(la[ind],ra[ind]);
		if(f)work(lca[ind]);
    }
    for(int i=1;i<=q;i++)
    	printf("%d\n",ans[i]);
	return 0;
}