import core.stdc.stdio;
import std.typecons;
import std.algorithm;

struct Seg{
	Seg* l,r;
	int c;
}

int Count(Seg* x){
	return x is null?0:x.c;
}

Seg* Left(Seg* x){
	return x is null?null:x.l;
}

Seg* Right(Seg* x){
	return x is null?null:x.r;
}

Seg[] buf;
Seg* newSeg(Seg* l,Seg* r){
	static int i;
	buf[i]=Seg(l,r,l.Count+r.Count);
	return &buf[i++];
}

Seg* Add(Seg* x,int i,int l=0,int r=1<<30){
	if(i<l||r<=i)
		return x;
	if(i==l&&i+1==r){
		Seg* t=newSeg(null,null);
		t.c=1+x.Count;
		return t;
	}else
		return newSeg(Add(x.Left,i,l,(l+r)/2),Add(x.Right,i,(l+r)/2,r));
}

int Get(Seg* x,int i,int l=0,int r=1<<30){
	if(x is null)
		return 0;
	if(i<=l)
		return 0;
	if(r<=i)
		return x.Count;
	return Get(x.Left,i,l,(l+r)/2)+Get(x.Right,i,(l+r)/2,r);
}

int[][] par;
int[] dep;
void LCA_Init(){
	foreach(i;1..20)
		foreach(j,ref p;par[i])
			p=par[i-1][j]>=0?par[i-1][par[i-1][j]]:-1;
}

int LCA(int a,int b){
	if(dep[a]>dep[b])
		swap(a,b);
	int d=dep[b]-dep[a];
	foreach(i;0..20)
		if((d>>i)&1)
			b=par[i][b];
	if(a==b)
		return a;
	foreach_reverse(i;0..20)
		if(par[i][a]!=par[i][b])
			a=par[i][a],b=par[i][b];
	return par[0][a];
}

void main(){
	buf = new Seg[6000000];
	int n,q;
	scanf("%d%d",&n,&q);
	int[] x=new int[n];
	foreach(ref v;x)
		scanf("%d",&v);
	int[][] graph=new int[][n];
	foreach(i;0..n-1){
		int a,b;
		scanf("%d%d",&a,&b);
		graph[--a]~=--b;
		graph[b]~=a;
	}
	
	Seg*[] segs=new Seg*[n];
	par=new int[][](20,n);
	dep=new int[n];
	
	alias Tuple!(int,"i",int,"p",Seg*,"s",int,"d") stack;
	stack[] st=new stack[n*2];
	st[0]=stack(0,-1,null,0);
	int ss=1;
	while(ss){
		stack cur=st[--ss];
		with(cur){
			par[0][i]=p;
			dep[i]=d;
			segs[i]=s.Add(x[i]);
			foreach(c;graph[i])
				if(c!=p)
					st[ss++]=stack(c,i,segs[i],d+1);
		}
	}
	LCA_Init;
	
	foreach(_;0..q){
		int v,w,k,l=0,r=1<<30;
		scanf("%d%d%d",&v,&w,&k);
		int p=LCA(--v,--w);
		Seg* a=segs[v],b=segs[w],c=segs[p],d=p?segs[par[0][p]]:null;
		while(r-l>1){
			int m=(r+l)/2;
			if(k<=a.Get(m)+b.Get(m)-c.Get(m)-d.Get(m))
				r=m;
			else
				l=m;
		}
		printf("%d\n",l);
	}
}