#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define lowbit(x) ((x)&(-(x)))
#define mid ((l+r)>>1)
#define lson rt<<1, l, mid
#define rson rt<<1|1, mid+1, r
#define fors(i, a, b) for(int i = (a); i < (b); ++i)
using namespace std;
namespace fast_io {
    const int BUFSIZE = 50 << 20;
    char Buf[BUFSIZE + 1], *buf = Buf;
    char OBuf[BUFSIZE + 1] , *obuf = OBuf;

    void init() {
        Buf[fread(Buf, 1, BUFSIZE, stdin)] = 0;
    }

    void flush() {
        fwrite(OBuf, 1, obuf - OBuf, stdout);
    }

    template <class T>
    void read(T &x) {
        x = 0;
        while (!isdigit(*buf)) buf++;
        while (isdigit(*buf)) { x *= 10; x += *buf - '0'; buf++; }
    }

    template <class T>
    void pt(T u) {
		int a[25], *q = a;
		if (!u) *obuf++ = '0';
		else {
			while (u) *q++ = u % 10 + '0' , u /= 10;
			while (q != a) *obuf++ = *--q;
		}
	}

    template <class T>
    void print(T a) {
		pt(a), *obuf++ = '\n';
	}

}
#define read fast_io::read
#define print fast_io::print
const int B = 773;
const int maxn = 6e5 + 5;
struct node{
    int l, r, id, x, y, p;
    bool operator < (const node& x) const{
        if(l/B != x.l/B) return l < x.l;
        return ((l/B)&1) ? (r < x.r) : (r > x.r);
    }
}e[maxn];
int n, q, a[maxn];
vector<int> g[maxn];
int in[maxn],out[maxn], idx=0, dfn[maxn];
int f[maxn][20], dep[maxn];
void dfs(int u, int fa){
    f[u][0] = fa, dep[u]=dep[fa]+1;
    fors(i,0,19) f[u][i+1]=f[f[u][i]][i];
    dfn[in[u]=++idx] = u;
    for(int v: g[u]) if(fa!=v) dfs(v,u);
    dfn[out[u]=++idx] = u;
    return;
}
int lca(int u, int v){
    if(dep[u]<dep[v]) swap(u,v);
    int d = dep[u]-dep[v];fors(i,0,19)if(d>>i&1)u=f[u][i];
    if(u==v) return u;
    for(int i = 19; i >= 0; --i) if(f[u][i]!=f[v][i])u=f[u][i],v=f[v][i];
    return f[u][0];
}
int ex[maxn];
int h[maxn],s=0;
const int BB = 500;
void add(int x){
    h[x]^=1; int id = x/BB;
    (h[x])?++ex[id]:--ex[id];
}
int qry(int l, int r){
    int id1 = l/BB, id2 = r/BB;
    if(id1==id2){
        fors(i,l,r+1) if(h[i]) return i;
        return -1;
    }
    if(ex[id1])fors(i,l,(id1+1)*BB) if(h[i]) return i;
    if(ex[id2])fors(i,id2*BB,r+1) if(h[i]) return i;
    fors(i,id1+1,id2){
        if(!ex[i]) continue;
        fors(j,i*BB,(i+1)*BB) if(h[j]) return j;
    }return -1;
}
int ans[maxn];
int main()
{
    fast_io::init();
    read(n); read(q);
    fors(i,1,n+1) read(a[i]);
    fors(i,1,n){
        int u, v; read(u); read(v); g[u].pb(v); g[v].pb(u);
    }
    dfs(1,0);
    int tot = 0;
    fors(i,0,q){
        int u, v, l, r;
        read(u); read(v); read(l); read(r);
        if(u==v){
            if(l<=a[u] && a[u]<=r) ans[i] = a[u];
            else ans[i] = -1;
        }else {
            if(in[u]>in[v]) swap(u,v);
            int p = lca(u, v);
            if(dep[u]+dep[v]-2*dep[p]<=300){
                int x=u,y=v;
                while(x!=p) add(a[x]),x=f[x][0];
                while(y!=p) add(a[y]),y=f[y][0];
                add(a[p]);
                ans[i] = qry(l, r);
                x=u,y=v;
                while(x!=p) add(a[x]),x=f[x][0];
                while(y!=p) add(a[y]),y=f[y][0];
                add(a[p]);
                continue;
            }
            if(p == u){
                e[tot++] = (node){in[u],in[v],i,l,r,0};
            }else{
                e[tot++] = (node){out[u],in[v],i,l,r,p};
            }
        }
    }
    sort(e,e+tot);
    int lp = 1, rp = 0;
    fors(i,0,tot){
        while(rp<e[i].r) add(a[dfn[++rp]]);
        while(lp>e[i].l) add(a[dfn[--lp]]);
        while(rp>e[i].r) add(a[dfn[rp--]]);
        while(lp<e[i].l) add(a[dfn[lp++]]);
        if(e[i].p) add(a[e[i].p]);
        ans[e[i].id] = qry(e[i].x, e[i].y);
        if(e[i].p) add(a[e[i].p]);
    }
    fors(i,0,q) printf("%d\n", ans[i]);
    fast_io::flush();
	return 0;
}
