#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cstdlib>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
int n,m,x,y,z,l,r,a[300005];
int rt[300005],ls[12000005],rs[12000005],tot;
ull c[300005],val[12000005];
int head[300005],to[600005],nex[600005],cnt;
int fa[300005][19],dep[300005];
inline ull rd(){
	ull res=0;
	for(int i=0;i<=60;i+=15)
		res^=(ull)rand()<<i;
	return res;
}
void modify(int &u,int v,int l,int r,int x,ull y){
	u=++tot;
	ls[u]=ls[v];rs[u]=rs[v];val[u]=val[v]^y;
	if(l<r){
		int mid=(l+r)>>1;
		if(x<=mid)modify(ls[u],ls[v],l,mid,x,y);
		else modify(rs[u],rs[v],mid+1,r,x,y);
	}
}
int query(int u1,int u2,int u3,int u4,int l,int r,int x,int y){
	if(!(val[u1]^val[u2]^val[u3]^val[u4]))return -1;
	if(l==r)return l;
	int mid=(l+r)>>1,res=-1;
	if(x<=mid)res=query(ls[u1],ls[u2],ls[u3],ls[u4],l,mid,x,y);
	if(~res)return res;
	if(y>mid)res=query(rs[u1],rs[u2],rs[u3],rs[u4],mid+1,r,x,y);
	return res;
}
inline void adde(int f,int t){
	to[++cnt]=t;
	nex[cnt]=head[f];
	head[f]=cnt;
}
void dfs(int u,int pre){
	fa[u][0]=pre;dep[u]=dep[pre]+1;
	for(int i=1;i<=18;++i)
		fa[u][i]=fa[fa[u][i-1]][i-1];
	modify(rt[u],rt[pre],1,n,a[u],c[a[u]]);
	for(int i=head[u],v;i;i=nex[i]){
		v=to[i];
		if(v==pre)continue;
		dfs(v,u);
	}
}
inline int lca(int x,int y){
	if(dep[x]<dep[y])swap(x,y);
	int t=dep[x]-dep[y];
	for(int i=0;i<=18;++i)
		if((t>>i)&1)x=fa[x][i];
	if(x==y)return x;
	for(int i=18;~i;--i){
		if(fa[x][i]!=fa[y][i]){
			x=fa[x][i];
			y=fa[y][i];
		}
	}
	return fa[x][0];
}
int main(){
	srand(19491001);
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;++i){
		scanf("%d",a+i);
		c[i]=rd();
	}
	for(int i=1;i<n;++i){
		scanf("%d%d",&x,&y);
		adde(x,y);adde(y,x);
	}
	dfs(1,0);
	while(m--){
		scanf("%d%d%d%d",&x,&y,&l,&r);
		z=lca(x,y);
		printf("%d\n",query(rt[x],rt[y],rt[z],rt[fa[z][0]],1,n,l,r));
	}
	return 0;
}