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 TopBit(int a){
	foreach_reverse(i;0..20)
		if((a>>i)&1)
			return i;
	assert(false);
}

alias Tuple!(int,"d",int,"i") di;
di[][] rmq;
void LCA_Init(di[] d){
	int l=cast(int)d.length;
	int h=l.TopBit+1;
	rmq=new di[][](h,l);
	rmq[0]=d;
	foreach(i;1..h)
		foreach(j;0..l)
			rmq[i][j]=min(rmq[i-1][j],rmq[i-1][min(l-1,j+(1<<i-1))]);
}

int LCA(int a,int b){
	if(a>b)
		swap(a,b);
	int h=TopBit(++b-a);
	return min(rmq[h][a],rmq[h][b-(1<<h)]).i;
}

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];
	di[] et=new di[2*n-1];
	int e;
	int[] ei=new int[n];
	int[] par=new int[n];
	
	void DFS(int i,int p,Seg* s,int d){
		par[i]=p;
		segs[i]=s.Add(x[i]);
		ei[i]=e;
		et[e++]=di(d,i);
		foreach(c;graph[i])
			if(c!=p){
				DFS(c,i,segs[i],d+1);
				et[e++]=di(d,i);
			}
	}
	DFS(0,-1,null,0);
	et.LCA_Init;
	
	foreach(_;0..q){
		int v,w,k;
		scanf("%d%d%d",&v,&w,&k);
		int p=LCA(ei[--v],ei[--w]);
		Seg* a=segs[v],b=segs[w],c=segs[p],d=p?segs[par[p]]:null;
		int l=0,r=1<<30;
		while(r-l>1){
			int m=(r+l)/2;
			int s=a.Get(m)+b.Get(m)-c.Get(m)-d.Get(m);
			if(k<=s)
				r=m;
			else
				l=m;
		}
		printf("%d\n",l);
	}
}